Skip to content

Commit 4bfcb36

Browse files
author
Rik Smale
committed
test: split normalizeEmail sanitizer tests
1 parent e0e0e7c commit 4bfcb36

1 file changed

Lines changed: 2 additions & 27 deletions

File tree

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
1-
import { format } from 'util';
2-
import validator from '../src/index';
1+
import test from '../testFunctions';
32

4-
function test(options) {
5-
let args = options.args || [];
6-
7-
args.unshift(null);
8-
9-
Object.keys(options.expect).forEach((input) => {
10-
args[0] = input;
11-
let result = validator[options.sanitizer](...args);
12-
let expected = options.expect[input];
13-
if (isNaN(result) && !result.length && isNaN(expected)) {
14-
return;
15-
}
16-
17-
if (result !== expected) {
18-
let warning = format(
19-
'validator.%s(%s) returned "%s" but should have returned "%s"',
20-
options.sanitizer, args.join(', '), result, expected
21-
);
22-
23-
throw new Error(warning);
24-
}
25-
});
26-
}
27-
28-
describe('Sanitizers', () => {
3+
describe('normalizeEmail', () => {
294
it('should normalize an email based on domain', () => {
305
test({
316
sanitizer: 'normalizeEmail',

0 commit comments

Comments
 (0)