Skip to content

Commit 2751883

Browse files
committed
fix tests
1 parent eced2c7 commit 2751883

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

examples/ecommerce-netlify-functions/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"netlify-cli": "10.7.1"
1010
},
1111
"scripts": {
12-
"seed": "env NODE_ENV=development node ./seed",
13-
"start": "env NODE_ENV=development netlify dev",
12+
"seed": "env NODE_ENV=local node ./seed",
13+
"start": "env NODE_ENV=local netlify dev",
1414
"test": "env NODE_ENV=test mocha ./test/*.test.js"
1515
}
1616
}

examples/ecommerce-netlify-functions/seed.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const mongoose = require('mongoose');
66

77
async function createProducts() {
88
await mongoose.connect(config.mongodbUri);
9+
await mongoose.connection.dropDatabase();
910

1011
await Product.create({
1112
name: 'iPhone 12',

examples/ecommerce-netlify-functions/test/addToCart.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ const fixtures = require('../test/fixtures');
88

99
describe('Add to Cart', function() {
1010
it('Should create a cart and add a product to the cart', async function() {
11-
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
12-
.then((res) => res.products);
11+
const products = await fixtures.createProducts({
12+
product: [
13+
{ name: 'A Test Products', price: 500 },
14+
{ name: 'Another Test Product', price: 600 }
15+
]
16+
}).then((res) => res.products);
1317
const params = {
1418
body: {
1519
cartId: null,

examples/ecommerce-netlify-functions/test/checkout.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ const stripe = require('../integrations/stripe')
1111

1212
describe('Checkout', function() {
1313
it('Should do a successful checkout run', async function() {
14-
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
15-
.then((res) => res.products);
14+
const products = await fixtures.createProducts({
15+
product: [
16+
{ name: 'A Test Products', price: 500 },
17+
{ name: 'Another Test Product', price: 600 }
18+
]
19+
}).then((res) => res.products);
1620
const params = {
1721
body: {
1822
cartId: null,

examples/ecommerce-netlify-functions/test/getProducts.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ const mongoose = require('mongoose');
88

99
describe('Products', function() {
1010
it('Should get all products.', async function() {
11-
await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
12-
.then((res) => res.products);
11+
await fixtures.createProducts({
12+
product: [
13+
{ name: 'A Test Products', price: 500 },
14+
{ name: 'Another Test Product', price: 600 }
15+
]
16+
}).then((res) => res.products);
1317
const result = await getProducts();
1418
assert(result);
1519
});

examples/ecommerce-netlify-functions/test/removeFromCart.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ const fixtures = require('./fixtures');
99

1010
describe('Remove From Cart', function() {
1111
it('Should create a cart and then it should remove the entire item from it.', async function() {
12-
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
13-
.then((res) => res.products);
12+
const products = await fixtures.createProducts({
13+
product: [
14+
{ name: 'A Test Products', price: 500 },
15+
{ name: 'Another Test Product', price: 600 }
16+
]
17+
}).then((res) => res.products);
1418
const params = {
1519
body: {
1620
cartId: null,

0 commit comments

Comments
 (0)