mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* utils for products generator * load test for each *.test.js file in packages folder * [test] unit test for utils/common * refactor all products with productGenerator for all examples * refactor folder structure * move component <Code /> to src/components/common * rename component file name
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { productsGenerator } from '../../src/utils/common';
|
|
|
|
describe('Utils', () => {
|
|
describe('productsGenerator', () => {
|
|
const quantity = 2;
|
|
|
|
it('should return an array', () => {
|
|
expect(Array.isArray(productsGenerator())).toBe(true);
|
|
});
|
|
|
|
it('should return 5 products without params', () => {
|
|
expect(productsGenerator().length).toEqual(5);
|
|
});
|
|
|
|
it('should return an array with given quntity', () => {
|
|
expect(productsGenerator(quantity).length).toEqual(quantity);
|
|
});
|
|
|
|
describe('when callback is defined', () => {
|
|
const callback = (value, index) => ({
|
|
id: index,
|
|
name: 'react-bootstrap-table-2'
|
|
});
|
|
|
|
it('should return customized products format', () => {
|
|
const products = productsGenerator(quantity, callback);
|
|
const product = products[0];
|
|
|
|
expect(Array.isArray(products)).toBe(true);
|
|
expect(products.length).toBe(quantity);
|
|
expect(product).toHaveProperty('id', 0);
|
|
expect(product).toHaveProperty('name', 'react-bootstrap-table-2');
|
|
});
|
|
});
|
|
});
|
|
});
|