forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminnotifies.test.js
109 lines (75 loc) · 2.44 KB
/
adminnotifies.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
'use strict';
require('should');
var language = require('../lib/language')();
const ctx = {};
ctx.bus = {};
ctx.bus.on = function mockOn(channel, f) { };
ctx.settings = {};
ctx.settings.adminNotifiesEnabled = true;
const mockJqueryResults = {};
const mockButton = {};
mockButton.click = function() {};
mockButton.css = function() {};
mockButton.show = function() {};
const mockDrawer = {};
const mockJQuery = function mockJquery(p) {
if (p == '#adminnotifies') return mockButton;
if (p == '#adminNotifiesDrawer') return mockDrawer;
return mockJqueryResults;
};
const mockClient = {};
mockClient.translate = language.translate;
mockClient.headers = function () {return {};}
const adminnotifies = require('../lib/adminnotifies')(ctx);
var window = {};
//global.window = window;
window.setTimeout = function () { return; }
describe('adminnotifies', function ( ) {
after( function tearDown(done) {
delete global.window;
done();
});
it('should aggregate a message', function () {
const notify = {
title: 'Foo'
, message: 'Bar'
};
adminnotifies.addNotify(notify);
adminnotifies.addNotify(notify);
const notifies = adminnotifies.getNotifies();
notifies.length.should.equal(1);
});
/*
it('should display a message', function (done) {
const notify2 = {
title: 'FooFoo'
, message: 'BarBar'
};
adminnotifies.addNotify(notify2);
adminnotifies.addNotify(notify2);
const notifies = adminnotifies.getNotifies();
mockJQuery.ajax = function mockAjax() {
const rVal = notifies;
rVal.done = function(callback) {
callback({
message: {
notifies,
notifyCount: notifies.length
}
});
return rVal;
}
rVal.fail = function() {};
return rVal;
}
const adminnotifiesClient = require('../lib/client/adminnotifiesclient')(mockClient,mockJQuery);
mockDrawer.html = function (html) {
console.log(html);
html.indexOf('You have administration messages').should.be.greaterThan(0);
html.indexOf('Event repeated 2 times').should.be.greaterThan(0);
done();
}
adminnotifiesClient.prepare();
});
*/
});