Add failing test case for stringifyJSON

This commit is contained in:
Warren Seymour 2020-09-03 08:22:47 +01:00
parent cd4f022671
commit b3083e5ba5

View File

@ -7,6 +7,8 @@ import App from '../src/app/containers/App';
import api from '../src/app/middlewares/api';
import exportState from '../src/app/middlewares/exportState';
import rootReducer from '../src/app/reducers';
import { DATA_TYPE_KEY } from '../src/app/constants/dataTypes';
import stringifyJSON from '../src/app/utils/stringifyJSON';
let wrapper;
@ -43,3 +45,25 @@ describe('App container', () => {
).toMatch(/<div class="actionListRows-\d-\d-\d+"><\/div>/);
});
});
describe('stringifyJSON', () => {
it('should not mutate the source object', () => {
const src = {
isTest: true,
[DATA_TYPE_KEY]: 'Test',
};
const result = {
data: {
isTest: true,
},
__serializedType__: 'Test',
};
expect(stringifyJSON(src, true)).toEqual(JSON.stringify(result));
expect(src).toEqual({
isTest: true,
[DATA_TYPE_KEY]: 'Test',
});
});
});