Skip to content

Commit ccce66a

Browse files
author
Rik Smale
committed
test: split tests of large validators
1 parent 90c19e8 commit ccce66a

15 files changed

+12539
-13320
lines changed

Diff for: test/sanitizers.test.js

+1-228
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { format } from 'util';
22
import validator from '../src/index';
33

4-
function test(options) {
4+
export default function test(options) {
55
let args = options.args || [];
66

77
args.unshift(null);
@@ -284,231 +284,4 @@ describe('Sanitizers', () => {
284284
},
285285
});
286286
});
287-
288-
it('should normalize an email based on domain', () => {
289-
test({
290-
sanitizer: 'normalizeEmail',
291-
expect: {
292-
293-
294-
295-
296-
297-
298-
299-
300-
301-
302-
'hans@m端ller.com': 'hans@m端ller.com',
303-
304-
305-
'"foo@bar"@baz.com': '"foo@bar"@baz.com',
306-
307-
308-
309-
310-
311-
312-
'@gmail.com': false,
313-
'@icloud.com': false,
314-
'@outlook.com': false,
315-
'@yahoo.com': false,
316-
},
317-
});
318-
319-
// Testing all_lowercase switch, should apply to domains not known to be case-insensitive
320-
test({
321-
sanitizer: 'normalizeEmail',
322-
args: [{ all_lowercase: false }],
323-
expect: {
324-
325-
'hans@m端ller.com': 'hans@m端ller.com',
326-
'[email protected]': '[email protected]', // Hostname is always lowercased
327-
328-
// In case of domains that are known to be case-insensitive, there's a separate switch
329-
330-
331-
332-
333-
334-
335-
336-
337-
338-
339-
},
340-
});
341-
342-
// Testing *_lowercase
343-
test({
344-
sanitizer: 'normalizeEmail',
345-
args: [{
346-
all_lowercase: false,
347-
gmail_lowercase: false,
348-
icloud_lowercase: false,
349-
outlookdotcom_lowercase: false,
350-
yahoo_lowercase: false,
351-
yandex_lowercase: false,
352-
}],
353-
expect: {
354-
'[email protected]': '[email protected]', // all_lowercase
355-
'[email protected]': '[email protected]', // gmail_lowercase
356-
'[email protected]': '[email protected]', // icloud_lowercase
357-
'[email protected]': '[email protected]', // icloud_lowercase
358-
'[email protected]': '[email protected]', // outlookdotcom_lowercase
359-
'[email protected]': '[email protected]', // outlookdotcom_lowercase
360-
'[email protected]': '[email protected]', // yahoo_lowercase
361-
'[email protected]': '[email protected]', // yandex_lowercase
362-
},
363-
});
364-
365-
// Testing all_lowercase
366-
// Should overwrite all the *_lowercase options
367-
test({
368-
sanitizer: 'normalizeEmail',
369-
args: [{
370-
all_lowercase: true,
371-
gmail_lowercase: false, // Overruled
372-
icloud_lowercase: false, // Overruled
373-
outlookdotcom_lowercase: false, // Overruled
374-
yahoo_lowercase: false, // Overruled
375-
}],
376-
expect: {
377-
'[email protected]': '[email protected]', // all_lowercase
378-
'[email protected]': '[email protected]', // gmail_lowercase
379-
'[email protected]': '[email protected]', // icloud_lowercase
380-
'[email protected]': '[email protected]', // icloud_lowercase
381-
'[email protected]': '[email protected]', // outlookdotcom_lowercase
382-
'[email protected]': '[email protected]', // outlookdotcom_lowercase
383-
'[email protected]': '[email protected]', // yahoo_lowercase
384-
},
385-
});
386-
387-
// Testing *_remove_dots
388-
test({
389-
sanitizer: 'normalizeEmail',
390-
args: [{
391-
gmail_remove_dots: false,
392-
}],
393-
expect: {
394-
395-
396-
397-
},
398-
});
399-
400-
test({
401-
sanitizer: 'normalizeEmail',
402-
args: [{
403-
gmail_remove_dots: true,
404-
}],
405-
expect: {
406-
407-
408-
409-
410-
},
411-
});
412-
413-
// Testing *_remove_subaddress
414-
test({
415-
sanitizer: 'normalizeEmail',
416-
args: [{
417-
gmail_remove_subaddress: false,
418-
icloud_remove_subaddress: false,
419-
outlookdotcom_remove_subaddress: false,
420-
yahoo_remove_subaddress: false, // Note Yahoo uses "-"
421-
}],
422-
expect: {
423-
424-
'[email protected]': '[email protected]', // gmail_remove_subaddress
425-
'[email protected]': '[email protected]', // icloud_remove_subaddress
426-
'[email protected]': '[email protected]', // icloud_remove_subaddress
427-
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
428-
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
429-
'[email protected]': '[email protected]', // yahoo_remove_subaddress
430-
'[email protected]': '[email protected]', // yahoo_remove_subaddress
431-
},
432-
});
433-
434-
test({
435-
sanitizer: 'normalizeEmail',
436-
args: [{
437-
gmail_remove_subaddress: true,
438-
icloud_remove_subaddress: true,
439-
outlookdotcom_remove_subaddress: true,
440-
yahoo_remove_subaddress: true, // Note Yahoo uses "-"
441-
}],
442-
expect: {
443-
444-
'[email protected]': '[email protected]', // gmail_remove_subaddress
445-
'[email protected]': '[email protected]', // icloud_remove_subaddress
446-
'[email protected]': '[email protected]', // icloud_remove_subaddress
447-
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
448-
'[email protected]': '[email protected]', // outlookdotcom_remove_subaddress
449-
'[email protected]': '[email protected]', // yahoo_remove_subaddress
450-
'[email protected]': '[email protected]', // yahoo_remove_subaddress
451-
},
452-
});
453-
454-
// Testing gmail_convert_googlemaildotcom
455-
test({
456-
sanitizer: 'normalizeEmail',
457-
args: [{
458-
gmail_convert_googlemaildotcom: false,
459-
}],
460-
expect: {
461-
462-
463-
464-
465-
466-
467-
},
468-
});
469-
470-
test({
471-
sanitizer: 'normalizeEmail',
472-
args: [{
473-
gmail_convert_googlemaildotcom: true,
474-
}],
475-
expect: {
476-
477-
478-
479-
480-
481-
482-
},
483-
});
484-
485-
// Testing yandex_convert_yandexru
486-
test({
487-
sanitizer: 'normalizeEmail',
488-
args: [{
489-
yandex_convert_yandexru: false,
490-
}],
491-
expect: {
492-
493-
494-
495-
496-
497-
},
498-
});
499-
500-
test({
501-
sanitizer: 'normalizeEmail',
502-
args: [{
503-
yandex_convert_yandexru: true,
504-
}],
505-
expect: {
506-
507-
508-
509-
510-
511-
},
512-
});
513-
});
514287
});

0 commit comments

Comments
 (0)