| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { expect } from 'chai';
- import {
- getDocs
- } from 'selectors/crud';
- describe('CRUD selectors', () => {
- describe('getDocs', () => {
- const route = 'employees';
- it('should return the list of docs', () => {
- const state = {
- crud: {
- [route]: {
- items: [
- {
- id: '<actualId>',
- name: 'John Doe',
- email: 'john.doe@mubaloo.com'
- }
- ]
- }
- }
- };
- const result = getDocs(state, route);
- expect(result).to.deep.equal(state.crud[route].items);
- });
- it('should return an empty array by default', () => {
- const state = {
- crud: {}
- };
- const result = getDocs(state, route);
- expect(result).to.deep.equal([]);
- });
- it('should memoise default results', () => {
- const state = {
- crud: {}
- };
- const resultA = getDocs(state, route);
- const resultB = getDocs(state, route);
- expect(resultA).to.equal(resultB);
- });
- });
- });
|