mirror of
https://github.com/logto-io/logto.git
synced 2025-02-24 22:05:56 -05:00
19 lines
776 B
TypeScript
19 lines
776 B
TypeScript
|
import { domainRegEx } from './regex.js';
|
||
|
|
||
|
describe('Regular expressions should work as expected', () => {
|
||
|
it('should allow valid domains that consists of 3 parts. E.g. foo.bar.com', () => {
|
||
|
expect(domainRegEx.test('foo.bar.com')).toBe(true);
|
||
|
expect(domainRegEx.test('foo1.bar.com')).toBe(true);
|
||
|
expect(domainRegEx.test('foo.bar1.com')).toBe(true);
|
||
|
expect(domainRegEx.test('1foo.bar.com')).toBe(true);
|
||
|
expect(domainRegEx.test('f.bar.co')).toBe(true);
|
||
|
expect(domainRegEx.test('f.b.com')).toBe(true);
|
||
|
expect(domainRegEx.test('1.b.tk')).toBe(true);
|
||
|
});
|
||
|
|
||
|
it('should not allow domains that consists of 2 parts. E.g. bar.com', () => {
|
||
|
expect(domainRegEx.test('bar.com')).toBe(false);
|
||
|
expect(domainRegEx.test('b.co')).toBe(false);
|
||
|
});
|
||
|
});
|