Adds more tests for domain name + fixes regex

This commit is contained in:
Akshay Nair committed 2020-10-04 13:46:05 +05:30
1 parent e042b69b2a
commit cc5018eea4
3 files changed
+27 -15

No files matched your search

+22 -13
View File
@@ -12,30 +12,39 @@ describe('Domains', () => {
describe('validateDomainData', () => {
it('should return true if the name is invalid', () => {
const { valid, errors } = validateDomainData({
name: 'hello world',
forceHttps: true,
record: { CNAME: ['hello.com'] },
const names = ['hello world', 'good12312++123', 'ajsdjasdaSD_123yuqehq', 'khsda%', '', undefined, '12112**dsd', Array(101).fill('a').join('')];
names.forEach(name => {
const { valid, errors } = validateDomainData({
name,
forceHttps: true,
record: { CNAME: ['hello.com'] },
});
expect(valid).toBe(false);
expect(errors.length).toBe(1);
expect(errors[0][0]).toBe('name');
});
expect(valid).toBe(false);
expect(errors[0][0]).toBe('name');
});
it('should return true for a valid object', () => {
const { valid, errors } = validateDomainData({
name: 'something',
forceHttps: true,
record: { CNAME: ['hello.com'] },
const names = ['hello', 'hello-world', '11111111111', '--wow--', 'wow--', '--wow'];
names.forEach(name => {
const { valid, errors } = validateDomainData({
name,
forceHttps: true,
record: { CNAME: ['hello.com'] },
});
expect(valid).toBe(true);
expect(errors).toEqual([]);
});
expect(valid).toBe(true);
expect(errors).toEqual([]);
});
});
});
xit('should have a the correct keys', async () => {
it('should have a the correct keys', async () => {
const list = await getDomains();
list.forEach(data => {
console.log(data);
const { errors } = validateDomainData(data);
if (errors.length) {
console.log(errors);