Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 20, 2022
1 parent eced2c7 commit 2751883
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/ecommerce-netlify-functions/package.json
Expand Up @@ -9,8 +9,8 @@
"netlify-cli": "10.7.1"
},
"scripts": {
"seed": "env NODE_ENV=development node ./seed",
"start": "env NODE_ENV=development netlify dev",
"seed": "env NODE_ENV=local node ./seed",
"start": "env NODE_ENV=local netlify dev",
"test": "env NODE_ENV=test mocha ./test/*.test.js"
}
}
1 change: 1 addition & 0 deletions examples/ecommerce-netlify-functions/seed.js
Expand Up @@ -6,6 +6,7 @@ const mongoose = require('mongoose');

async function createProducts() {
await mongoose.connect(config.mongodbUri);
await mongoose.connection.dropDatabase();

await Product.create({
name: 'iPhone 12',
Expand Down
8 changes: 6 additions & 2 deletions examples/ecommerce-netlify-functions/test/addToCart.test.js
Expand Up @@ -8,8 +8,12 @@ const fixtures = require('../test/fixtures');

describe('Add to Cart', function() {
it('Should create a cart and add a product to the cart', async function() {
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
.then((res) => res.products);
const products = await fixtures.createProducts({
product: [
{ name: 'A Test Products', price: 500 },
{ name: 'Another Test Product', price: 600 }
]
}).then((res) => res.products);
const params = {
body: {
cartId: null,
Expand Down
8 changes: 6 additions & 2 deletions examples/ecommerce-netlify-functions/test/checkout.test.js
Expand Up @@ -11,8 +11,12 @@ const stripe = require('../integrations/stripe')

describe('Checkout', function() {
it('Should do a successful checkout run', async function() {
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
.then((res) => res.products);
const products = await fixtures.createProducts({
product: [
{ name: 'A Test Products', price: 500 },
{ name: 'Another Test Product', price: 600 }
]
}).then((res) => res.products);
const params = {
body: {
cartId: null,
Expand Down
8 changes: 6 additions & 2 deletions examples/ecommerce-netlify-functions/test/getProducts.test.js
Expand Up @@ -8,8 +8,12 @@ const mongoose = require('mongoose');

describe('Products', function() {
it('Should get all products.', async function() {
await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
.then((res) => res.products);
await fixtures.createProducts({
product: [
{ name: 'A Test Products', price: 500 },
{ name: 'Another Test Product', price: 600 }
]
}).then((res) => res.products);
const result = await getProducts();
assert(result);
});
Expand Down
Expand Up @@ -9,8 +9,12 @@ const fixtures = require('./fixtures');

describe('Remove From Cart', function() {
it('Should create a cart and then it should remove the entire item from it.', async function() {
const products = await fixtures.createProducts({product: [{ productName: 'A Test Products', productPrice: 500 }, {productName: 'Another Test Product', productPrice: 600 }]})
.then((res) => res.products);
const products = await fixtures.createProducts({
product: [
{ name: 'A Test Products', price: 500 },
{ name: 'Another Test Product', price: 600 }
]
}).then((res) => res.products);
const params = {
body: {
cartId: null,
Expand Down

0 comments on commit 2751883

Please sign in to comment.