Skip to content

Commit 3f304c0

Browse files
adding new test for getCopyData function
1 parent 10dda15 commit 3f304c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/utils/api/api.factory.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,13 @@ describe('Api.prototype.getPreviousData and Api.prototype.getData : ', () => {
432432
obj.updateState({selectedTabID: 'tab1', openTabIDs: ['tab1', 'tab2']});
433433
obj.trigger('onLoad', obj.userProxy);
434434
});
435+
test('it should return a copy of data and so data would be immutable', () => {
436+
obj.updateStateRef({selectedTabID: 'tab1', openTabIDs: ['tab1', 'tab2']}, () => {});
437+
const FirstCopyData = obj.getCopyData();
438+
FirstCopyData.newProp = 1;
439+
FirstCopyData.openTabIDs = [];
440+
expect(obj.getCopyData()).toEqual({selectedTabID: 'tab1', openTabIDs: ['tab1', 'tab2']}, () => {});
441+
});
435442
test('returned data should be equal to currentData in onLoad event', () => {
436443
expect.assertions(1);
437444
obj.setOption('onLoad', function () {

0 commit comments

Comments
 (0)