-
Notifications
You must be signed in to change notification settings - Fork 953
Expand file tree
/
Copy pathremoveURLsSpec.js
More file actions
52 lines (51 loc) · 2.41 KB
/
removeURLsSpec.js
File metadata and controls
52 lines (51 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import removeURLs from "../../../../src/languageProcessing/helpers/sanitize/removeURLs.js";
describe( "a test for removing URLs from a string", function() {
it( "removes a base URL", function() {
expect( removeURLs( "https://example.com" ) ).toBe( "" );
} );
it( "removes a URL followed by a subdirectory", function() {
expect( removeURLs( "https://example.com/example1" ) ).toBe( "" );
} );
it( "removes a URL followed by multiple subdirectories", function() {
expect( removeURLs( "https://example.com/example1/part1" ) ).toBe( "" );
} );
it( "removes a URL with a subdomain", function() {
expect( removeURLs( "https://blog.example.com/examples" ) ).toBe( "" );
} );
it( "removes a URL starting with http://", function() {
expect( removeURLs( "http://blog.example.com/examples" ) ).toBe( "" );
} );
it( "removes a URL containing www.", function() {
expect( removeURLs( "http://www.blog.example.com/examples" ) ).toBe( "" );
} );
it( "removes a URL starting with www.", function() {
expect( removeURLs( "www.blog.example.com/examples" ) ).toBe( "" );
} );
it( "removes a URL starting with ftp", function() {
expect( removeURLs( "ftp://example.com" ) ).toBe( "" );
} );
it( "removes a URL containing special characters.", function() {
expect( removeURLs( "https://www.example.com/foo/?bar=baz&inga=42&quux" ) ).toBe( "" );
} );
it( "removes a URL containing a semi-colon.", function() {
expect( removeURLs( "https://www.example.com/foo/?bar=baz&inga=42&quux" ) ).toBe( "" );
} );
it( "removes a URL containing more special characters.", function() {
expect( removeURLs( "http://foo.com/blah_(wikipedia)_blah#cite-1" ) ).toBe( "" );
} );
it( "removes a URL with a different top-level domain", function() {
expect( removeURLs( "http://example.co.uk" ) ).toBe( "" );
} );
it( "removes a URL followed by Japanese characters", function() {
expect( removeURLs( "https://example.comこれに対し日本国有鉄道" ) ).toBe( "これに対し日本国有鉄道" );
} );
it( "does not remove a URL that doesn't start with 'http(s)://', 'ftp://' or 'www'.", function() {
expect( removeURLs( "example.com" ) ).toBe( "example.com" );
} );
it( "does not remove https:// on its own", function() {
expect( removeURLs( "https://" ) ).toBe( "https://" );
} );
it( "does not remove a URL without a top-level domain", function() {
expect( removeURLs( "https://example" ) ).toBe( "https://example" );
} );
} );