UNPKG

@neocoast/neox

Version:

Data structure supporting new redux hooks

39 lines (38 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require(".."); describe('toJS function', () => { let state; const initialState = { year: 2020, username: 'tintef', test: 'maurocen', data: { testingLibrary: 'jest', }, numbers: [4, 8, 15, 16, 23, 42], }; beforeAll(() => { state = __1.default(initialState); }); test('should return an object', (done) => { expect(state.toJS()).toBeInstanceOf(Object); done(); }); test('should return the same keys', (done) => { const newState = state.toJS(); expect(Object.keys(newState)).toEqual(Object.keys(initialState)); done(); }); test('should return the same values', (done) => { const newState = state.toJS(); expect(Object.values(newState)).toEqual(Object.values(initialState)); done(); }); test('should maintain inner references unchanged', (done) => { const newState = state.toJS(); expect(newState.data).toBe(initialState.data); expect(newState.numbers).toBe(initialState.numbers); done(); }); });