File size: 989 Bytes
1e92f2d | 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 | import { parseDomainAgainstTldList } from '../';
describe( 'parseDomainAgainstTldList', () => {
const tldList = {
'co.in': 1,
'co.uk': 1,
};
test( 'should return an empty string if domain fragment is missing', () => {
expect( parseDomainAgainstTldList( '', tldList ) ).toEqual( '' );
} );
test( 'should return an empty string if the tld is not a known one', () => {
expect( parseDomainAgainstTldList( 'example.co.yz', tldList ) ).toEqual( '' );
} );
test( 'should return domain fragment if it exists in the list of known tlds', () => {
expect( parseDomainAgainstTldList( 'co.uk', tldList ) ).toEqual( 'co.uk' );
} );
test( 'should return the right multi-level tld with a subdomain', () => {
expect( parseDomainAgainstTldList( 'example.co.uk', tldList ) ).toEqual( 'co.uk' );
} );
test( 'should return the right multi-level tld with a sub-subdomain', () => {
expect( parseDomainAgainstTldList( 'test.example.co.uk', tldList ) ).toEqual( 'co.uk' );
} );
} );
|