-
Notifications
You must be signed in to change notification settings - Fork 386
Expand file tree
/
Copy pathtest-parse-mailbox-names.js
More file actions
58 lines (44 loc) · 1.63 KB
/
test-parse-mailbox-names.js
File metadata and controls
58 lines (44 loc) · 1.63 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var parseExpr = require('../lib/Parser').parseExpr;
var assert = require('assert'),
inspect = require('util').inspect;
[
{ source: '(\HasNoChildren) "." SimpleName',
expected: [ [ 'HasNoChildren' ], '.', "SimpleName" ],
what: 'Simple mailbox name'
},
{ source: '(\HasNoChildren) "." "SimpleNameQuoted"',
expected: [ [ 'HasNoChildren' ], '.', "SimpleNameQuoted" ],
what: 'Quoted mailbox name'
},
{ source: '(\HasNoChildren) "." "Simple Name Quoted With Spaces"',
expected: [ [ 'HasNoChildren' ], '.', "Simple Name Quoted With Spaces" ],
what: 'Quoted mailbox name with spaces'
},
{ source: '(\HasNoChildren) "." [NameWithBrackets].AndChild',
expected: [ [ 'HasNoChildren' ], '.', [ 'NameWithBrackets' ], '.AndChild' ],
what: 'Mailbox name containings brackets'
},
{ source: '(\HasNoChildren) "." "[Name With Quotes Spaces Brackets.AndChild]"',
expected: [ [ 'HasNoChildren' ], '.', '[Name With Quotes Spaces Brackets.AndChild]' ],
what: 'Mailbox name containings quotes, spaces and brackets'
},
].forEach(function(v) {
var result;
try {
result = parseExpr(v.source, null, null, false);
} catch (e) {
console.log(makeMsg(v.what, 'JS Exception: ' + e.stack));
return;
}
assert.deepEqual(result,
v.expected,
makeMsg(v.what,
'Result mismatch:'
+ '\nParsed: ' + inspect(result, false, 10)
+ '\nExpected: ' + inspect(v.expected, false, 10)
)
);
});
function makeMsg(what, msg) {
return '[' + what + ']: ' + msg;
}