const generateChannel = communityId => { const name = faker.commerce.department(); return { id: uuid(), communityId, createdAt: faker.date.past(2), name, description: casual.short_description(), slug: slugify(name), isPrivate: faker.random.boolean(), isDefault: false, }; }
async function addProduct(data) { const defaultProduct = { name: faker.commerce.product(), price: faker.finance.amount(), weight: faker.random.number() }; const body = Object.assign(defaultProduct, data); return await queryApi("POST", "/products", { body }); }
it('POST should create a new page', function(done) { const test_page = { name: faker.commerce.productName(), menuId: faker.random.uuid(), userId: DUMMY_USER.id, }; chai.request(server) .post('/v1/pages') .set('Authorization', global.HEADER_TOKEN) .send(test_page) .end((err, res) => { expect(err).to.be.null; expect(res.body.success).to.be.true; expect(res.body.page).to.be.an('object').that.include.all.keys('id', 'name', 'menuId', 'userId'); expect(res.status).to.be.equal(201); done(); }); })
const run = async () => { await producer.connect(); setInterval(() => { producer.send({ topic: "products", messages: [ { value: JSON.stringify({ id: v4(), name: faker.commerce.productName(), type: faker.commerce.product().toUpperCase(), event: faker.helpers.shuffle(['CREATED', 'UPDATED', 'PURCHASED'])[0], version: "v1", }), }, ], }); }, 3000) }
it('PUT should update an existing post', function(done) { const newPostTitle = faker.commerce.productName(); chai.request(server) .put('/v1/posts/'+global.DUMMY_POST.id) .set('Authorization', global.HEADER_TOKEN) .send({ title: newPostTitle }) .end((err, res) => { expect(err).to.be.null; expect(res.body.success).to.be.true; expect(res.body.post).to.be.an('object').that.include.all.keys('id', 'title', 'author', 'content','tags', 'pageURL'); expect(res.body.post.title).to.equal(newPostTitle); expect(res.status).to.be.equal(200); done(); }); })
router.get('/', function (req, res, next) { const categories = ["Baby", "Movies", "Shoes", "Books", "Electronics","Computers", "Kids"]; for (let i = 0; i < 20; i++) { let product = new Product({ name : faker.commerce.productName(), price : faker.commerce.price(), category: categories[Math.floor(Math.random() * categories.length)], description : faker.lorem.paragraph(), image: "https://images-na.ssl-images-amazon.com/images/I/4196ru-rkjL.jpg" }); product.save(); } for (let i = 0; i < categories.length; i++) { let cat = new Category({ title: categories[i] }); cat.save(); } res.redirect('/') });
it('PUT should update existing page', function(done) { const newPageName = faker.commerce.productName(); chai.request(server) .put('/v1/pages/'+DUMMY_PAGE.id) .set('Authorization', global.HEADER_TOKEN) .send({ name: newPageName }) .end((err, res) => { expect(err).to.be.null; expect(res.body.success).to.be.true; expect(res.body.page).to.be.an('object').that.include.all.keys('id', 'name', 'menuId', 'userId'); expect(res.body.page.name).to.equal(newPageName); expect(res.status).to.be.equal(200); done(); }); })
var color = faker.commerce.color(); /* random color */ var materialBrand = faker.commerce.productMaterial(); /* random material */ brand = brands[brandNum]; imagePath = '/img/' + brand.toLowerCase() + '-printer.jpg' name = faker.commerce.productName() + ' Printer'; price = Math.floor((Math.random() * 100000 - 1) + 1); cost = Math.floor((Math.random() * price) + (price / 2)); title = faker.commerce.productAdjective() + ' ' + color + ' ' + name slug = title.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with -
async.times(100, function(i, next) { var color = faker.commerce.color(); color = color.toUpperCase(); var materialBrand = faker.commerce.productMaterial(); brand = brands[brandNum]; imagePath = '/img/' + brand.toLowerCase() + '-refrigerator.jpg' name = faker.commerce.productName() + ' Refrigerator'; price = faker.commerce.price(); cost = Math.floor(Math.random() * price) + (price / 2) brand = brands[brandNum]; imagePath = '/img/' + brand.toLowerCase() + '-refrigerator.jpg' name = faker.commerce.productName() + ' Refrigerator'; price = Math.floor((Math.random() * 100000 - 1) + 1); cost = Math.floor((Math.random() * price) + (price / 2)); pgroup = Math.floor((Math.random() * product_groups.length - 1) + 1); product_group = product_groups[pgroup]; title = faker.commerce.productAdjective() + ' ' + color + ' ' + name slug = title.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with -
}; var code = parseInt(1000 + i); var color = faker.commerce.color(); var materialBrand = faker.commerce.productMaterial(); typeNum = Math.floor((Math.random() * brands.length - 1) + 1); brandNum = Math.floor((Math.random() * brands.length - 1) + 1); imagePath = '/img/' + type + '-clothes.jpg' var category = 'Apparel'; name = faker.commerce.productName() + ' ' + type; price = Math.floor((Math.random() * 10000 - 1) + 1); cost = Math.floor((Math.random() * price) + (price / 2)); title = brand + ' ' + faker.commerce.productAdjective() + ' ' + color + ' ' + name slug = title.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with -
var color = faker.commerce.color(); var materialBrand = faker.commerce.productMaterial(); pgroup = Math.floor((Math.random() * product_groups.length - 1) + 1); product_group = product_groups[pgroup]; imagePath = '/img/' + brand.toLowerCase() + '-camera.jpg' var category = 'Camera'; name = faker.commerce.productName() + ' Camera'; price = Math.floor((Math.random() * 100000 - 1) + 1); cost = Math.floor((Math.random() * price) + (price / 2)); }, name: name, title: brand + ' ' + faker.commerce.productAdjective() + ' ' + color + ' ' + name, description: faker.lorem.sentence(), taxable: 'Yes',
/** * Issue a request to the API to add a product * @param data {object|} Specify product data. If not provided, use faker to get fixture. * @returns {Promise<*>} */ async add(data) { const defaultProduct = { name: faker.commerce.product(), price: faker.finance.amount(), weight: faker.random.number() }; const body = Object.assign(defaultProduct, data); return await queryAPI('POST', '/products', {body}); }
async function addProduct(data) { const defaultProduct = { name: faker.commerce.product(), price: faker.finance.amount(), weight: faker.random.number() }; const body = Object.assign(defaultProduct, data); return await queryApi("POST", "/products", { body }); }
async function addProduct(data) { const defaultProduct = { name: faker.commerce.product(), price: faker.finance.amount(), weight: faker.random.number() }; const body = Object.assign(defaultProduct, data); return await queryApi("POST", "/products", { body }); }