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

Commit 943916c

Browse files
Add test for logs length + making sure tail is kept
1 parent c0fb552 commit 943916c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/unit/action/log.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Store } from '../../../src/store';
2+
import { EventEmitter } from 'events';
23
import * as log from '../../../src/action/log';
34
import LogAction from '../../../src/action/log';
45

@@ -38,6 +39,28 @@ describe('Action Logs Unit Tests', () => {
3839
});
3940
});
4041

42+
describe('constructor', () => {
43+
let ipcRendererStub;
44+
45+
beforeEach(() => {
46+
store = new Store();
47+
ipcRendererStub = new EventEmitter();
48+
ipcRendererStub.send = sinon.stub();
49+
new LogAction(store, ipcRendererStub);
50+
});
51+
52+
describe('constructor()', () => {
53+
it('should keep logs trimmed to 100 and keep the tail of the logs', () => {
54+
for (var i = 0; i < 101; i++) {
55+
ipcRendererStub.emit('logs', 'some-event', i.toString());
56+
}
57+
expect(store.logs.length, 'to equal', 100);
58+
expect(store.logs[0], 'to equal', '1');
59+
expect(store.logs[99], 'to equal', '100');
60+
});
61+
});
62+
});
63+
4164
describe('with constructor', () => {
4265
beforeEach(() => {
4366
store = new Store();

0 commit comments

Comments
 (0)