| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- import { expect } from 'chai';
- import {
- DOC_CREATED,
- DOC_CREATE_RESPONDED,
- DOC_READ,
- DOC_READ_RESPONDED,
- DOC_UPDATED,
- DOC_UPDATE_RESPONDED,
- DOC_DELETED,
- DOC_DELETE_RESPONDED
- } from 'constants/actions';
- import {
- docCreated,
- docCreateResponded,
- docRead,
- docReadResponded,
- docUpdated,
- docUpdateResponded,
- docDeleted,
- docDeleteResponded
- } from 'actions/crud';
- describe('CRUD actions', () => {
- describe('docCreated', () => {
- it('should return DOC_CREATED with fields', () => {
- const route = 'employees';
- const pendingId = 'mypendingid';
- const fields = {
- name: 'Foo',
- email: 'foo@mubaloo.com'
- };
- const action = docCreated(route, pendingId, fields);
- expect(action).to.deep.equal({
- type: DOC_CREATED,
- route,
- pendingId,
- fields
- });
- });
- });
- describe('docCreateResponded', () => {
- it('should return DOC_CREATE_RESPONDED with error / response', () => {
- const route = 'employees';
- const pendingId = 'mypendingid';
- const error = { error: true };
- const response = { response: true };
- const action = docCreateResponded(route, pendingId, error, response);
- expect(action).to.deep.equal({
- type: DOC_CREATE_RESPONDED,
- route,
- pendingId,
- err: error,
- response
- });
- });
- });
- describe('docRead', () => {
- it('should return DOC_READ', () => {
- const route = 'employees';
- const action = docRead(route);
- expect(action).to.deep.equal({
- type: DOC_READ,
- route
- });
- });
- });
- describe('docReadResponded', () => {
- it('should return DOC_READ_RESPONDED with error / response', () => {
- const route = 'employees';
- const error = { error: true };
- const response = { response: true };
- const action = docReadResponded(route, error, response);
- expect(action).to.deep.equal({
- type: DOC_READ_RESPONDED,
- route,
- err: error,
- response
- });
- });
- });
- describe('docUpdated', () => {
- it('should return DOC_UPDATED', () => {
- const route = 'employees';
- const id = 'a8b8ce23';
- const fields = {
- name: 'Bar'
- };
- const action = docUpdated(route, id, fields);
- expect(action).to.deep.equal({
- type: DOC_UPDATED,
- route,
- id,
- fields
- });
- });
- });
- describe('docUpdateResponded', () => {
- it('should return DOC_UPDATE_RESPONDED with error / response', () => {
- const route = 'employees';
- const id = 'a0fb56';
- const error = { error: true };
- const response = { response: true };
- const action = docUpdateResponded(route, id, error, response);
- expect(action).to.deep.equal({
- type: DOC_UPDATE_RESPONDED,
- route,
- id,
- err: error,
- response
- });
- });
- });
- describe('docDeleted', () => {
- it('should return DOC_DELETED', () => {
- const route = 'employees';
- const id = 'a8b8ce23';
- const action = docDeleted(route, id);
- expect(action).to.deep.equal({
- type: DOC_DELETED,
- route,
- id
- });
- });
- });
- describe('docDeleteResponded', () => {
- it('should return DOC_DELETE_RESPONDED with error', () => {
- const route = 'employees';
- const id = 'a0fb56';
- const error = { error: true };
- const action = docDeleteResponded(route, id, error);
- expect(action).to.deep.equal({
- type: DOC_DELETE_RESPONDED,
- route,
- id,
- err: error
- });
- });
- });
- });
|