mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 18:42:40 +00:00
Add more ID validation test cases
This commit is contained in:
@@ -128,7 +128,7 @@ describe('Tests for api', ()=>{
|
|||||||
expect(googleId).toEqual('123456789012345678901234567890123');
|
expect(googleId).toEqual('123456789012345678901234567890123');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw invalid google id', ()=>{
|
it('should throw invalid - google id right length but does not match pattern', ()=>{
|
||||||
let err;
|
let err;
|
||||||
try {
|
try {
|
||||||
api.getId({
|
api.getId({
|
||||||
@@ -146,6 +146,42 @@ describe('Tests for api', ()=>{
|
|||||||
expect(err).toEqual({ HBErrorCode: '12', brewId: 'abcdefghijkl', message: 'Invalid ID', name: 'Google ID Error', status: 404 });
|
expect(err).toEqual({ HBErrorCode: '12', brewId: 'abcdefghijkl', message: 'Invalid ID', name: 'Google ID Error', status: 404 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw invalid - google id too short (32 char)', ()=>{
|
||||||
|
let err;
|
||||||
|
try {
|
||||||
|
api.getId({
|
||||||
|
params : {
|
||||||
|
id : 'abcdefghijkl'
|
||||||
|
},
|
||||||
|
body : {
|
||||||
|
googleId : '12345678901234567890123456789012'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
err = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(err).toEqual({ HBErrorCode: '12', brewId: 'abcdefghijkl', message: 'Invalid ID', name: 'Google ID Error', status: 404 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw invalid - google id too long (45 char)', ()=>{
|
||||||
|
let err;
|
||||||
|
try {
|
||||||
|
api.getId({
|
||||||
|
params : {
|
||||||
|
id : 'abcdefghijkl'
|
||||||
|
},
|
||||||
|
body : {
|
||||||
|
googleId : '123456789012345678901234567890123456789012345'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
err = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(err).toEqual({ HBErrorCode: '12', brewId: 'abcdefghijkl', message: 'Invalid ID', name: 'Google ID Error', status: 404 });
|
||||||
|
});
|
||||||
|
|
||||||
it('should return 12-char id and google id from params', ()=>{
|
it('should return 12-char id and google id from params', ()=>{
|
||||||
const { id, googleId } = api.getId({
|
const { id, googleId } = api.getId({
|
||||||
params : {
|
params : {
|
||||||
|
|||||||
Reference in New Issue
Block a user