imapflow 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +8 -0
- package/lib/charsets.js +1 -4
- package/lib/commands/append.js +1 -1
- package/lib/commands/copy.js +3 -24
- package/lib/commands/copyuid-parser.js +33 -0
- package/lib/commands/idle.js +5 -7
- package/lib/commands/list.js +1 -1
- package/lib/commands/move.js +4 -27
- package/lib/commands/store.js +1 -3
- package/lib/handler/imap-compiler.js +1 -3
- package/lib/handler/imap-formal-syntax.js +1 -7
- package/lib/handler/imap-parser.js +1 -1
- package/lib/handler/imap-stream.js +7 -13
- package/lib/handler/parser-instance.js +2 -2
- package/lib/handler/token-parser.js +9 -9
- package/lib/imap-flow.js +80 -117
- package/lib/search-compiler.js +4 -10
- package/lib/tools.js +29 -36
- package/package.json +2 -2
- package/test/charsets-test.js +161 -0
- package/test/commands-integration-test.js +61 -0
- package/test/connection-edge-cases-test.js +94 -0
- package/test/copyuid-parser-test.js +153 -0
- package/test/imap-compiler-test.js +66 -0
- package/test/imap-formal-syntax-test.js +275 -0
- package/test/imap-stream-edge-cases-test.js +268 -0
- package/test/imapflow-test.js +212 -0
- package/test/search-compiler-test.js +74 -0
- package/test/token-parser-test.js +374 -0
- package/test/tools-test.js +149 -2
package/test/tools-test.js
CHANGED
|
@@ -270,6 +270,13 @@ module.exports['Tools: getFlagColor with color bits'] = test => {
|
|
|
270
270
|
test.done();
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
+
module.exports['Tools: getFlagColor with all bits set (index 7) defaults to red'] = test => {
|
|
274
|
+
// bit0=1, bit1=2, bit2=4 => color=7, FLAG_COLORS[7] is undefined => defaults to 'red'
|
|
275
|
+
let flags = new Set(['\\Flagged', '$MailFlagBit0', '$MailFlagBit1', '$MailFlagBit2']);
|
|
276
|
+
test.equal(tools.getFlagColor(flags), 'red');
|
|
277
|
+
test.done();
|
|
278
|
+
};
|
|
279
|
+
|
|
273
280
|
// ============================================
|
|
274
281
|
// getColorFlags tests
|
|
275
282
|
// ============================================
|
|
@@ -284,11 +291,11 @@ module.exports['Tools: getColorFlags with valid color'] = test => {
|
|
|
284
291
|
};
|
|
285
292
|
|
|
286
293
|
module.exports['Tools: getColorFlags with red (index 0)'] = test => {
|
|
287
|
-
// 'red' is index 0
|
|
294
|
+
// 'red' is index 0 — should add \\Flagged and remove all MailFlagBit flags
|
|
288
295
|
let result = tools.getColorFlags('red');
|
|
289
296
|
test.ok(Array.isArray(result.add));
|
|
290
297
|
test.ok(Array.isArray(result.remove));
|
|
291
|
-
test.ok(result.
|
|
298
|
+
test.ok(result.add.includes('\\Flagged'));
|
|
292
299
|
test.done();
|
|
293
300
|
};
|
|
294
301
|
|
|
@@ -990,3 +997,143 @@ module.exports['Tools: AuthenticationFailure error class'] = test => {
|
|
|
990
997
|
test.equal(error.message, 'Auth failed');
|
|
991
998
|
test.done();
|
|
992
999
|
};
|
|
1000
|
+
|
|
1001
|
+
// ============================================
|
|
1002
|
+
// enhanceCommandError tests
|
|
1003
|
+
// ============================================
|
|
1004
|
+
|
|
1005
|
+
module.exports['Tools: enhanceCommandError sets serverResponseCode'] = async test => {
|
|
1006
|
+
let err = new Error('Command failed');
|
|
1007
|
+
err.response = {
|
|
1008
|
+
tag: '*',
|
|
1009
|
+
command: 'NO',
|
|
1010
|
+
attributes: [
|
|
1011
|
+
{
|
|
1012
|
+
type: 'SECTION',
|
|
1013
|
+
section: [{ type: 'ATOM', value: 'NONEXISTENT' }]
|
|
1014
|
+
},
|
|
1015
|
+
{ type: 'ATOM', value: 'Mailbox' },
|
|
1016
|
+
{ type: 'ATOM', value: 'not' },
|
|
1017
|
+
{ type: 'ATOM', value: 'found' }
|
|
1018
|
+
]
|
|
1019
|
+
};
|
|
1020
|
+
let result = await tools.enhanceCommandError(err);
|
|
1021
|
+
test.equal(result.serverResponseCode, 'NONEXISTENT');
|
|
1022
|
+
test.equal(typeof result.response, 'string');
|
|
1023
|
+
test.done();
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
module.exports['Tools: enhanceCommandError with no status code'] = async test => {
|
|
1027
|
+
let err = new Error('Command failed');
|
|
1028
|
+
err.response = { tag: '*', command: 'NO' };
|
|
1029
|
+
let result = await tools.enhanceCommandError(err);
|
|
1030
|
+
test.ok(!result.serverResponseCode);
|
|
1031
|
+
test.done();
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
module.exports['Tools: enhanceCommandError with null response'] = async test => {
|
|
1035
|
+
let err = new Error('Command failed');
|
|
1036
|
+
err.response = null;
|
|
1037
|
+
let result = await tools.enhanceCommandError(err);
|
|
1038
|
+
test.equal(result.response, false);
|
|
1039
|
+
test.done();
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
// ============================================
|
|
1043
|
+
// getDecoder additional tests
|
|
1044
|
+
// ============================================
|
|
1045
|
+
|
|
1046
|
+
module.exports['Tools: getDecoder with eucjp charset'] = test => {
|
|
1047
|
+
let decoder = tools.getDecoder('eucjp');
|
|
1048
|
+
test.ok(decoder);
|
|
1049
|
+
test.equal(decoder.constructor.name, 'JPDecoder');
|
|
1050
|
+
test.done();
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
module.exports['Tools: getDecoder with euc-jp (hyphenated) returns JPDecoder'] = test => {
|
|
1054
|
+
let decoder = tools.getDecoder('euc-jp');
|
|
1055
|
+
test.ok(decoder);
|
|
1056
|
+
test.equal(decoder.constructor.name, 'JPDecoder');
|
|
1057
|
+
test.done();
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
module.exports['Tools: getDecoder with jis charset'] = test => {
|
|
1061
|
+
let decoder = tools.getDecoder('jis');
|
|
1062
|
+
test.ok(decoder);
|
|
1063
|
+
test.equal(decoder.constructor.name, 'JPDecoder');
|
|
1064
|
+
test.done();
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
module.exports['Tools: getDecoder with windows-1252 returns iconv stream'] = test => {
|
|
1068
|
+
let decoder = tools.getDecoder('windows-1252');
|
|
1069
|
+
test.ok(decoder);
|
|
1070
|
+
test.notEqual(decoder.constructor.name, 'JPDecoder');
|
|
1071
|
+
test.ok(typeof decoder.write === 'function');
|
|
1072
|
+
test.done();
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
module.exports['Tools: getDecoder with no arg defaults to ascii'] = test => {
|
|
1076
|
+
let decoder = tools.getDecoder();
|
|
1077
|
+
test.ok(decoder);
|
|
1078
|
+
test.ok(typeof decoder.write === 'function');
|
|
1079
|
+
test.done();
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
// ============================================
|
|
1083
|
+
// getColorFlags tests
|
|
1084
|
+
// ============================================
|
|
1085
|
+
|
|
1086
|
+
module.exports['Tools: getColorFlags returns non-null for all valid colors'] = test => {
|
|
1087
|
+
let colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'grey'];
|
|
1088
|
+
for (let color of colors) {
|
|
1089
|
+
let result = tools.getColorFlags(color);
|
|
1090
|
+
test.ok(result, `getColorFlags('${color}') should not be null`);
|
|
1091
|
+
test.ok(Array.isArray(result.add), `${color} should have add array`);
|
|
1092
|
+
test.ok(Array.isArray(result.remove), `${color} should have remove array`);
|
|
1093
|
+
}
|
|
1094
|
+
test.done();
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
module.exports['Tools: getColorFlags red has Flagged but no MailFlagBit set'] = test => {
|
|
1098
|
+
let result = tools.getColorFlags('red');
|
|
1099
|
+
// red = index 0, all bits 0 — adds \\Flagged, removes all MailFlagBit flags
|
|
1100
|
+
test.ok(result.add.includes('\\Flagged'));
|
|
1101
|
+
test.ok(result.remove.includes('$MailFlagBit0'));
|
|
1102
|
+
test.ok(result.remove.includes('$MailFlagBit1'));
|
|
1103
|
+
test.ok(result.remove.includes('$MailFlagBit2'));
|
|
1104
|
+
test.done();
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
module.exports['Tools: getColorFlags orange has MailFlagBit0 set'] = test => {
|
|
1108
|
+
let result = tools.getColorFlags('orange');
|
|
1109
|
+
// orange = index 1, bit 0 set
|
|
1110
|
+
test.ok(result.add.includes('\\Flagged'));
|
|
1111
|
+
test.ok(result.add.includes('$MailFlagBit0'));
|
|
1112
|
+
test.ok(result.remove.includes('$MailFlagBit1'));
|
|
1113
|
+
test.ok(result.remove.includes('$MailFlagBit2'));
|
|
1114
|
+
test.done();
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
module.exports['Tools: getColorFlags yellow has MailFlagBit1 set'] = test => {
|
|
1118
|
+
let result = tools.getColorFlags('yellow');
|
|
1119
|
+
// yellow = index 2, bit 1 set
|
|
1120
|
+
test.ok(result.add.includes('\\Flagged'));
|
|
1121
|
+
test.ok(result.add.includes('$MailFlagBit1'));
|
|
1122
|
+
test.ok(result.remove.includes('$MailFlagBit0'));
|
|
1123
|
+
test.ok(result.remove.includes('$MailFlagBit2'));
|
|
1124
|
+
test.done();
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
module.exports['Tools: getColorFlags returns null for invalid color'] = test => {
|
|
1128
|
+
test.equal(tools.getColorFlags('invalid'), null);
|
|
1129
|
+
test.equal(tools.getColorFlags('pink'), null);
|
|
1130
|
+
test.done();
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
module.exports['Tools: getColorFlags with null returns result not null'] = test => {
|
|
1134
|
+
// null input: colorCode becomes null, which is not < 0, so it falls through
|
|
1135
|
+
let result = tools.getColorFlags(null);
|
|
1136
|
+
test.ok(result);
|
|
1137
|
+
test.ok(result.remove.includes('\\Flagged'));
|
|
1138
|
+
test.done();
|
|
1139
|
+
};
|