-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements input validation for the AplicationId
- Implements validation and tests - Improves some error messages on the CLI
- Loading branch information
Showing
4 changed files
with
107 additions
and
8 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
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 |
---|---|---|
|
@@ -137,4 +137,34 @@ describe('util', () => { | |
expect(result).toBe('com.appspot.pwa_directory_test.twa'); | ||
}); | ||
}); | ||
|
||
describe('#validatePackageId', () => { | ||
it('returns true for valid packages', () => { | ||
expect(util.validatePackageId('com.pwa_directory.appspot.com')).toBeTrue(); | ||
expect(util.validatePackageId('com.pwa1directory.appspot.com')).toBeTrue(); | ||
}); | ||
|
||
it('returns false for packages with invalid characters', () => { | ||
expect(util.validatePackageId('com.pwa-directory.appspot.com')).toBeFalse(); | ||
expect(util.validatePackageId('[email protected]')).toBeFalse(); | ||
expect(util.validatePackageId('com.pwa*directory.appspot.com')).toBeFalse(); | ||
}); | ||
|
||
it('returns false for packages empty sections', () => { | ||
expect(util.validatePackageId('com.example.')).toBeFalse(); | ||
expect(util.validatePackageId('.com.example')).toBeFalse(); | ||
expect(util.validatePackageId('com..example')).toBeFalse(); | ||
}); | ||
|
||
it('packages with less than 2 sections return false', () => { | ||
expect(util.validatePackageId('com')).toBeFalse(); | ||
expect(util.validatePackageId('')).toBeFalse(); | ||
}); | ||
|
||
it('packages starting with non-letters return false', () => { | ||
expect(util.validatePackageId('com.1char.twa')).toBeFalse(); | ||
expect(util.validatePackageId('1com.char.twa')).toBeFalse(); | ||
expect(util.validatePackageId('com.char.1twa')).toBeFalse(); | ||
}); | ||
}); | ||
}); |