Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 13f1f28

Browse files
committed
Add sinon stubs to tests to ensure functions are called.
1 parent d797650 commit 13f1f28

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/unit/action/log.spec.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ describe('Action Logs Unit Tests', () => {
99
let sandbox;
1010
let ipc;
1111
let ipcRenderer;
12-
13-
const RNFS = {
14-
DocumentDirectoryPath: '/foo/bar',
15-
readFile: () => Promise.resolve('logs'),
16-
};
17-
const Share = {
18-
share: () => Promise.resolve(true),
19-
};
12+
let RNFS;
13+
let Share;
2014

2115
beforeEach(() => {
2216
sandbox = sinon.createSandbox({});
2317
ipcRenderer = {
2418
send: sinon.stub(),
2519
on: sinon.stub().yields('some-event', 'some-arg'),
2620
};
21+
RNFS = {
22+
DocumentDirectoryPath: '/foo/bar',
23+
readFile: sinon.stub().resolves('logs'),
24+
};
25+
Share = {
26+
share: sinon.stub().resolves(true),
27+
};
2728
});
2829

2930
afterEach(() => {
@@ -143,6 +144,7 @@ describe('Action Logs Unit Tests', () => {
143144
it('should return logs with an FS constructor argument', async () => {
144145
new LogAction(store, ipc, false, RNFS);
145146
expect(await log.getLogs(), 'to be a string');
147+
expect(RNFS.readFile.called, 'to be true');
146148
});
147149
});
148150

@@ -154,6 +156,8 @@ describe('Action Logs Unit Tests', () => {
154156
it('should share the logs with a Share and FS constructor argument', async () => {
155157
new LogAction(store, ipc, false, RNFS, Share);
156158
expect(await log.shareLogs(), 'to be ok');
159+
expect(RNFS.readFile.called, 'to be true');
160+
expect(Share.share.called, 'to be true');
157161
});
158162
});
159163
});

0 commit comments

Comments
 (0)