Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit a220c0a

Browse files
committed
Add tests to normalize-url
1 parent 41d5f84 commit a220c0a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

shared/test/normalize-url.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @flow
2+
import normalizeUrl from '../normalize-url';
3+
4+
type Input = string;
5+
type Output = string;
6+
7+
// If only Input is provided it tests for input === output
8+
type TestCase = [Input, Output];
9+
10+
type TestCases = {
11+
[testName: string]: TestCase,
12+
};
13+
14+
const testCases: TestCases = {
15+
'should do nothing to https URLs': [
16+
'https://github.com',
17+
'https://github.com',
18+
],
19+
'should do nothing to http URLs': ['http://github.com', 'http://github.com'],
20+
'should add https:// in front of URLs without protocol': [
21+
'github.com',
22+
'https://github.com',
23+
],
24+
};
25+
26+
Object.keys(testCases).forEach(name => {
27+
it(name, () => {
28+
expect(normalizeUrl(testCases[name][0])).toEqual(testCases[name][1]);
29+
});
30+
});

0 commit comments

Comments
 (0)