This repository has been archived by the owner on Jul 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(project-validation): updates the regex and error style
- Loading branch information
1 parent
248eb41
commit 3b98978
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ProjectNameValidatorDirective } from './project-name.validator'; | ||
|
||
describe('should check pattern to valdidate Project name', () => { | ||
|
||
it('validate Project Name to be falsy if start with special character', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('#app-may-11-2018-1'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy if ends with special character', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app-may-11-2018-1@'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy if has any special character apart from - and _', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app-may-11-2018@1'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy if ends with _', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app-may-11-2018-1_'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy if ends with -', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app-may-11-2018-1-'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be truthy', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app-may-11-2018-1'); | ||
expect(valProjectName).toBeTruthy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy as length is not satisfied', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('ap'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be falsy as length is not satisfied', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('12345678901234567890123456789012345678901'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('validate Project Name to be truthy as length is satisfied', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('a123456789012345678901234567890123456789'); | ||
expect(valProjectName).toBeTruthy(); | ||
}); | ||
|
||
it('should return false if the project name has continous hyphens (-)', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app_name--name'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('should return false if the project name has continous underscores (_)', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app_name__name'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('should not allow project name with spaces', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('app_name name'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
it('should not allow project name starting with a number', () => { | ||
let valProjectName = ProjectNameValidatorDirective.pattern.test('1app_namename'); | ||
expect(valProjectName).toBeFalsy(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters