Skip to content

Commit 3c5b3b6

Browse files
EgoAleSumEgoAleSum
authored andcommitted
Adding tests for previous commit
1 parent 902fe68 commit 3c5b3b6

File tree

1 file changed

+138
-9
lines changed

1 file changed

+138
-9
lines changed

test/sanitizers.js

Lines changed: 138 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,36 +241,165 @@ describe('Sanitizers', function () {
241241
},
242242
});
243243

244+
// Testing all_lowercase switch, should apply to domains not known to be case-insensitive
244245
test({
245246
sanitizer: 'normalizeEmail',
246-
args: [{ lowercase: false }],
247+
args: [{ all_lowercase: false }],
247248
expect: {
248-
'test@me.com': 'test@me.com',
249+
'test@foo.com': 'test@foo.com',
249250
'hans@m端ller.com': 'hans@m端ller.com',
250-
'[email protected]': '[email protected]', // Hostname is always lowercased,
251-
252-
251+
'[email protected]': '[email protected]', // Hostname is always lowercased
253252
254-
// Domains that are known for being case-insensitive are always lowercased,
253+
// In case of domains that are known to be case-insensitive, there's a separate switch
254+
255+
255256
256257
257258
259+
260+
261+
262+
263+
},
264+
});
265+
266+
// Testing *_lowercase
267+
test({
268+
sanitizer: 'normalizeEmail',
269+
args: [{
270+
all_lowercase: false,
271+
gmail_lowercase: false,
272+
icloud_lowercase: false,
273+
outlookdotcom_lowercase: false,
274+
yahoo_lowercase: false,
275+
}],
276+
expect: {
277+
'[email protected]': '[email protected]', // all_lowercase
278+
'[email protected]': '[email protected]', // gmail_lowercase
279+
'[email protected]': '[email protected]', // icloud_lowercase
280+
'[email protected]': '[email protected]', // icloud_lowercase
281+
'[email protected]': '[email protected]', // outlookdotcom_lowercase
282+
'[email protected]': '[email protected]', // outlookdotcom_lowercase
283+
'[email protected]': '[email protected]', // yahoo_lowercase
284+
},
285+
});
286+
287+
// Testing all_lowercase
288+
// Should overwrite all the *_lowercase options
289+
test({
290+
sanitizer: 'normalizeEmail',
291+
args: [{
292+
all_lowercase: true,
293+
gmail_lowercase: false, // Overruled
294+
icloud_lowercase: false, // Overruled
295+
outlookdotcom_lowercase: false, // Overruled
296+
yahoo_lowercase: false, // Overruled
297+
}],
298+
expect: {
299+
'[email protected]': '[email protected]', // all_lowercase
300+
'[email protected]': '[email protected]', // gmail_lowercase
301+
'[email protected]': '[email protected]', // icloud_lowercase
302+
'[email protected]': '[email protected]', // icloud_lowercase
303+
'[email protected]': '[email protected]', // outlookdotcom_lowercase
304+
'[email protected]': '[email protected]', // outlookdotcom_lowercase
305+
'[email protected]': '[email protected]', // yahoo_lowercase
258306
},
259307
});
260308

309+
// Testing *_remove_dots
261310
test({
262311
sanitizer: 'normalizeEmail',
263-
args: [{ remove_dots: false }],
312+
args: [{
313+
gmail_remove_dots: false,
314+
}],
264315
expect: {
265316
317+
318+
319+
},
320+
});
321+
322+
test({
323+
sanitizer: 'normalizeEmail',
324+
args: [{
325+
gmail_remove_dots: true,
326+
}],
327+
expect: {
328+
329+
330+
266331
},
267332
});
268333

334+
// Testing *_remove_subaddress
269335
test({
270336
sanitizer: 'normalizeEmail',
271-
args: [{ remove_extension: false }],
337+
args: [{
338+
gmail_remove_subaddress: false,
339+
icloud_remove_subaddress: false,
340+
outlookdotcom_remove_subaddress: false,
341+
yahoo_remove_subaddress: false, // Note Yahoo uses "-"
342+
}],
272343
expect: {
273-
344+
345+
'[email protected]': '[email protected]', // gmail_remove_subaddress
346+
'[email protected]': '[email protected]', // icloud_remove_subaddress
347+
'[email protected]': '[email protected]', // icloud_remove_subaddress
348+
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
349+
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
350+
'[email protected]': '[email protected]', // yahoo_remove_subaddress
351+
'[email protected]': '[email protected]', // yahoo_remove_subaddress
352+
},
353+
});
354+
355+
test({
356+
sanitizer: 'normalizeEmail',
357+
args: [{
358+
gmail_remove_subaddress: true,
359+
icloud_remove_subaddress: true,
360+
outlookdotcom_remove_subaddress: true,
361+
yahoo_remove_subaddress: true, // Note Yahoo uses "-"
362+
}],
363+
expect: {
364+
365+
'[email protected]': '[email protected]', // gmail_remove_subaddress
366+
'[email protected]': '[email protected]', // icloud_remove_subaddress
367+
'[email protected]': '[email protected]', // icloud_remove_subaddress
368+
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
369+
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
370+
'[email protected]': '[email protected]', // yahoo_remove_subaddress
371+
'[email protected]': '[email protected]', // yahoo_remove_subaddress
372+
},
373+
});
374+
375+
// Testing gmail_convert_googlemaildotcom
376+
test({
377+
sanitizer: 'normalizeEmail',
378+
args: [{
379+
gmail_convert_googlemaildotcom: false,
380+
}],
381+
expect: {
382+
383+
384+
385+
386+
387+
388+
},
389+
});
390+
391+
test({
392+
sanitizer: 'normalizeEmail',
393+
args: [{
394+
gmail_convert_googlemaildotcom: true,
395+
}],
396+
expect: {
397+
398+
399+
400+
401+
402+
274403
},
275404
});
276405
});

0 commit comments

Comments
 (0)