-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
server-watcher-test.js
75 lines (60 loc) · 1.86 KB
/
server-watcher-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const expect = require('chai').expect;
const EOL = require('os').EOL;
const MockUI = require('console-ui/mock');
const MockAnalytics = require('../../helpers/mock-analytics');
const MockServerWatcher = require('../../helpers/mock-watcher');
const ServerWatcher = require('../../../lib/models/server-watcher');
describe('Server Watcher', function () {
let ui;
let analytics;
let watcher;
beforeEach(async function () {
ui = new MockUI();
analytics = new MockAnalytics();
watcher = new MockServerWatcher();
class ServerWatcherMock extends ServerWatcher {
setupBroccoliWatcher() {
this.watcher = watcher;
return super.setupBroccoliWatcher(...arguments);
}
}
await ServerWatcherMock.build({
ui,
analytics,
});
});
describe('watcher:change', function () {
beforeEach(function () {
watcher.emit('change', 'foo.txt');
});
it('logs that the file was changed', function () {
expect(ui.output).to.equal(`File changed: "foo.txt"${EOL}`);
});
it('does NOT tracks changes', function () {
expect(analytics.tracks).to.deep.equal([]);
});
});
describe('watcher:add', function () {
beforeEach(function () {
watcher.emit('add', 'foo.txt');
});
it('logs that the file was added', function () {
expect(ui.output).to.equal(`File added: "foo.txt"${EOL}`);
});
it('does NOT track additions', function () {
expect(analytics.tracks).to.deep.equal([]);
});
});
describe('watcher:delete', function () {
beforeEach(function () {
watcher.emit('delete', 'foo.txt');
});
it('logs that the file was deleted', function () {
expect(ui.output).to.equal(`File deleted: "foo.txt"${EOL}`);
});
it('does NOT tracks deletions', function () {
expect(analytics.tracks).to.deep.equal([]);
});
});
});