UNPKG

adastra-ui-comment

Version:

Testing locally 1) in this file - `npm i` install dependencies - `npm run build` or `npm run tsc` to build your module 2) in childApp - in package.json under dependencies add ui-astra-assets with file:(relativePathToRepo) - "ui-astra-a

47 lines 2.07 kB
import commentReducer from 'CommentSection/reducer'; import * as ActionTypes from 'CommentSection/constants'; import { action } from 'typesafe-actions'; describe('regMonReducer', () => { it('should initialize the initial state', () => { const createdAction = action(ActionTypes.FETCH_COMMENTS_FAILURE); const state = commentReducer(undefined, createdAction); expect(state.comments).toEqual([]); expect(state.users).toEqual([]); }); it('should save comments in state', () => { const createdAt = (new Date()).toString(); const testData = { message: 'test', author: 'testAuth', authorId: 'testId', createdDate: createdAt, isOwner: false, }; const createdAction = action(ActionTypes.FETCH_COMMENTS_SUCCESS, { comments: [Object.assign(Object.assign({}, testData), { id: '1' }), Object.assign(Object.assign({}, testData), { id: '2' })], }); const state = commentReducer(undefined, createdAction); const comment = state.comments[0]; const input = testData; expect(comment.author).toEqual(input.author); expect(comment.createdDate).toEqual(createdAt); expect(comment.message).toEqual(input.message); }); it('should save users in state', () => { const testData = { username: 'test', firstName: 'testFirst', lastName: 'testLast', }; const createdActionUser = action(ActionTypes.FETCH_USERS_SUCCESS, { users: [Object.assign(Object.assign({}, testData), { id: '1' }), Object.assign(Object.assign({}, testData), { id: '2' })], }); const state = commentReducer(undefined, createdActionUser); const user = state.users[0]; const input = testData; expect(user.username).toEqual(input.username); expect(user.firstName).toEqual(input.firstName); expect(user.lastName).toEqual(input.lastName); }); }); //# sourceMappingURL=reducer.test.js.map