-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.test.js
24 lines (21 loc) · 879 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const ReservedSubdomains = require('./index');
describe('ReservedSubdomains', () => {
it('catches valid and invalid domains', () => {
const valid = "this-is-valid";
const invalid = "www";
expect(ReservedSubdomains.isValid(valid)).toBe(true);
expect(ReservedSubdomains.isValid(invalid)).toBe(false);
expect(ReservedSubdomains.isNotValid(valid)).toBe(false);
expect(ReservedSubdomains.isNotValid(invalid)).toBe(true);
})
it('is case sensitive because it is developer responsibility to lowercase the inputs', () => {
const invalid = "www";
const invalidUpper = "WWW";
expect(ReservedSubdomains.isValid(invalid)).toBe(false);
expect(ReservedSubdomains.isValid(invalidUpper)).toBe(true);
})
it('validates against regex', () => {
const invalid = "server123";
expect(ReservedSubdomains.isValid(invalid)).toBe(false);
})
})