Browse Source

minor fixe throw Error

Vincent GUFFON 3 years ago
parent
commit
d31693e0e7

+ 3 - 3
services/connection/urlBuilder.ts

@@ -74,7 +74,7 @@ class UrlBuilder {
    */
   private static getEnumUrl (enumType?: string): string {
     if (typeof enumType === 'undefined') {
-      throw new TypeError('enumType must be defined')
+      throw new Error('enumType must be defined')
     }
     return UrlBuilder.concat(UrlBuilder.ROOT, 'enum', enumType)
   }
@@ -90,14 +90,14 @@ class UrlBuilder {
    */
   private static getModelUrl (model?: typeof Model, rootModel?: typeof Model, rootId?: number): string {
     if (typeof model === 'undefined') {
-      throw new TypeError('model must be defined')
+      throw new Error('model must be defined')
     }
 
     const entity = repositoryHelper.getEntity(model)
 
     if (typeof rootModel !== 'undefined') {
       if (typeof rootId === 'undefined') {
-        throw new TypeError('Root ID must be defined')
+        throw new Error('Root ID must be defined')
       }
 
       const rootUrl = UrlBuilder.getModelUrl(rootModel) as string

+ 1 - 1
tests/unit/composables/data/useMyProfile.spec.ts

@@ -26,7 +26,7 @@ beforeAll(() => {
 
 describe('setActivityYear()', () => {
   it('should throw an error if year is negative nor eq to 0', () => {
-   expect(() => useMyProfileMount.setActivityYear(-1)).toThrow()
+   expect(() => useMyProfileMount.setActivityYear(-1)).toThrowError('year must be positive')
   })
   it('should call updateStoreFromField', () => {
     repositoryHelperMock.updateStoreFromField = jest.fn()