-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathirc_utils_test.js
More file actions
40 lines (36 loc) · 1.18 KB
/
Copy pathirc_utils_test.js
File metadata and controls
40 lines (36 loc) · 1.18 KB
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
(function() {
"use strict";
describe("IRC Utils provides the following functions:", function() {
var waitsForArrayBufferConversion;
waitsForArrayBufferConversion = function() {
return waitsFor((function() {
return !window.irc.util.isConvertingArrayBuffers();
}), 'wait for array buffer conversion', 500);
};
describe("fromSocketData", function() {
var fromSocketData = irc.util.fromSocketData;
var ab, cb;
beforeEach(function() {
cb = jasmine.createSpy('cb');
});
describe("handles encoding", function() {
[
['UTF-8', [0x61, 0xE2, 0x9C, 0x93], 'a✓'],
['ISO-8859-1', [0x74, 0x73, 0x63, 0x68, 0xFC, 0xDF], 'tschüß']
].forEach(function(parts) {
var encoding = parts[0],
array = parts[1],
text = parts[2];
it(encoding, function() {
ab = irc.util.arrayToArrayBuffer(array);
fromSocketData(ab, cb);
waitsForArrayBufferConversion();
return runs(function() {
expect(cb).toHaveBeenCalledWith(text, encoding);
});
});
});
});
});
});
})();