Skip to content

Commit 064b6a3

Browse files
committed
✅ gets coverage of tests to 100%
1 parent c2e1c6f commit 064b6a3

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

__tests__/CS/customModule_CS-test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,42 @@ describe('customModule_CS.js', () => {
9292
expect(aModuleSpy).toHaveBeenCalledTimes(1);
9393
});
9494
});
95+
describe('test saveRecord', () => {
96+
const Record = new record.Record();
97+
describe('test errors', () => {
98+
const ErrorSpy = jest.spyOn(log, 'error');
99+
test('Should not throw any errors', () => {
100+
const ExecSaveRecord = customModule_CS.saveRecord({
101+
currentRecord: Record,
102+
});
103+
expect(
104+
jest.fn(() => {
105+
ExecSaveRecord;
106+
})
107+
).not.toThrow(Error);
108+
expect(ExecSaveRecord).toBeTruthy();
109+
expect(ErrorSpy).toHaveBeenCalledTimes(0);
110+
});
111+
test('Should catch errors', () => {
112+
const ExecSaveRecord = customModule_CS.saveRecord();
113+
expect(
114+
jest.fn(() => {
115+
ExecSaveRecord;
116+
})
117+
).not.toThrow(Error);
118+
expect(ExecSaveRecord).toBeTruthy();
119+
expect(ErrorSpy).toHaveBeenCalledTimes(1);
120+
});
121+
test("Doesn't allow save if no currentRecord property found", () => {
122+
const ExecSaveRecord = customModule_CS.saveRecord({});
123+
expect(
124+
jest.fn(() => {
125+
ExecSaveRecord;
126+
})
127+
).not.toThrow(Error);
128+
expect(ExecSaveRecord).toBeFalsy();
129+
expect(ErrorSpy).toHaveBeenCalledTimes(0);
130+
});
131+
});
132+
});
95133
});

0 commit comments

Comments
 (0)