mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-08-16 21:50:17 +00:00
examples enhance
* 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
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user