Vincent GUFFON 4 лет назад
Родитель
Сommit
a0516af3e1

+ 1 - 1
tests/unit/services/connection/connection.spec.ts

@@ -61,7 +61,7 @@ describe('invoke()', () => {
 
   describe('put()', () => {
     it('should throw an error if data missing', async () => {
-      expect(() => Connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL })).toThrow()
+      expect(() => Connection.invoke(HTTP_METHOD.PUT, 'users', { type: QUERY_TYPE.MODEL })).toThrowError('*args* is not a dataPersisterArgs')
     })
 
     it('should return item data', async () => {

+ 5 - 5
tests/unit/services/connection/urlBuilder.spec.ts

@@ -10,7 +10,7 @@ describe('invoke()', () => {
     it('should throw an error if URL is missing', () => {
       expect(() => UrlBuilder.build({
         type: QUERY_TYPE.DEFAULT
-      })).toThrow()
+      })).toThrowError('no url')
     })
 
     it('should return the URL concat with Root URL', () => {
@@ -25,7 +25,7 @@ describe('invoke()', () => {
     it('should throw an error if enumType is missing', () => {
       expect(() => UrlBuilder.build({
         type: QUERY_TYPE.ENUM
-      })).toThrow()
+      })).toThrowError('enumType must be defined')
     })
 
     it('should return the Enum URL concat with Root URL', () => {
@@ -40,7 +40,7 @@ describe('invoke()', () => {
     it('should throw an error if model is missing', () => {
       expect(() => UrlBuilder.build({
         type: QUERY_TYPE.MODEL
-      })).toThrow()
+      })).toThrowError('model must be defined')
     })
 
     it('should return the Model URL concat with Root URL', () => {
@@ -61,7 +61,7 @@ describe('invoke()', () => {
         type: QUERY_TYPE.MODEL,
         model: User,
         rootModel: Organization
-      })).toThrow()
+      })).toThrowError('Root ID must be defined')
     })
 
     it('should return the Root Model URL, Model Url concat with Root URL', () => {
@@ -96,7 +96,7 @@ describe('invoke()', () => {
     it('should throw an error if imgArgs is missing', () => {
       expect(() => UrlBuilder.build({
         type: QUERY_TYPE.IMAGE
-      })).toThrow()
+      })).toThrowError('*args* is not a dataProviderArgs')
     })
 
     it('should return the File download URL concat with Root URL', () => {

+ 1 - 1
tests/unit/services/rights/abilitiesUtils.spec.ts

@@ -92,7 +92,7 @@ describe('getAbilitiesByRoles()', () => {
 
 describe('getAbilitiesByConfig()', () => {
   it('should throw an error if the path is wrong', () => {
-    expect(() => abilitiesUtils.getAbilitiesByConfig('wrong_path')).toThrow()
+    expect(() => abilitiesUtils.getAbilitiesByConfig('wrong_path')).toThrowError()
   })
 })
 

+ 1 - 1
tests/unit/services/serializer/denormalizer/baseDenormalizer.spec.ts

@@ -5,6 +5,6 @@ class DummyDenormalizer extends BaseDenormalizer {}
 
 describe('support()', () => {
   it('should trow an error if support doesnt defined in DummyDenormalizer', () => {
-    expect(() => DummyDenormalizer.support(DENORMALIZER_TYPE.HYDRA)).toThrow()
+    expect(() => DummyDenormalizer.support(DENORMALIZER_TYPE.HYDRA)).toThrowError('Not implemented')
   })
 })

+ 1 - 1
tests/unit/services/serializer/denormalizer/yaml.spec.ts

@@ -14,7 +14,7 @@ describe('support()', () => {
 describe('denormalize()', () => {
   it('should throw an error if file doesnt exist', () => {
     const path = './tests/unit/fixture/files/not_exist_file.yaml'
-    expect(() => Yaml.denormalize({ path })).toThrow()
+    expect(() => Yaml.denormalize({ path })).toThrowError()
   })
 
   it('should parse a Yaml file and return a JSON Object', () => {

+ 1 - 1
tests/unit/services/serializer/normalizer/baseNormalizer.spec.ts

@@ -5,6 +5,6 @@ class DummyNormalizer extends BaseNormalizer {}
 
 describe('support()', () => {
   it('should trow an error if support doesnt defined in DummyNoramlizer', () => {
-    expect(() => DummyNormalizer.support(QUERY_TYPE.ENUM)).toThrow()
+    expect(() => DummyNormalizer.support(QUERY_TYPE.ENUM)).toThrowError('Not implemented')
   })
 })

+ 2 - 2
tests/unit/services/store/query.spec.ts

@@ -14,7 +14,7 @@ beforeEach(() => {
 
 describe('getItem()', () => {
   it('should throw an error if the Item is not found', () => {
-    expect(() => queryHelper.getItem(query, 1)).toThrow()
+    expect(() => queryHelper.getItem(query, 1)).toThrowError('item not found')
   })
 
   it('should return an Item', () => {
@@ -43,7 +43,7 @@ describe('getCollection()', () => {
 
 describe('getFlattenEntry()', () => {
   it('should throw an error if the Item is not found', () => {
-    expect(() => queryHelper.getFlattenEntry(query, 1)).toThrow()
+    expect(() => queryHelper.getFlattenEntry(query, 1)).toThrowError('item not found')
   })
 
   it('should find an Item and return a JSON flatten object', () => {

+ 3 - 3
tests/unit/services/store/repository.spec.ts

@@ -27,7 +27,7 @@ describe('getEntity()', () => {
 
 describe('updateStoreFromField()', () => {
   it('should throw an error if the field doest exist', () => {
-    expect(() => repositoryHelper.updateStoreFromField(User, {}, 'Foo Bar', 'name')).toThrow()
+    expect(() => repositoryHelper.updateStoreFromField(User, {}, 'Foo Bar', 'name')).toThrowError('field not found')
   })
 
   it('should update the store', () => {
@@ -41,7 +41,7 @@ describe('updateStoreFromField()', () => {
 
 describe('persist()', () => {
   it('should throw an error if the entry is empty', () => {
-    expect(() => repositoryHelper.persist(User, {})).toThrow()
+    expect(() => repositoryHelper.persist(User, {})).toThrowError()
   })
 
   it('should persist the entry inside the store', () => {
@@ -54,7 +54,7 @@ describe('persist()', () => {
 
 describe('findItemFromModel()', () => {
   it('should throw an error if the Item is not found', () => {
-    expect(() => repositoryHelper.findItemFromModel(User, 1)).toThrow()
+    expect(() => repositoryHelper.findItemFromModel(User, 1)).toThrowError('Item not found')
   })
 
   it('should return the correct item of the Model', () => {

+ 1 - 1
tests/unit/services/utils/modelsUtils.spec.ts

@@ -6,7 +6,7 @@ describe('extractIdFromUri()', () => {
   })
 
   it('should return Error if uri is not an number', () => {
-    expect(() => ModelsUtils.extractIdFromUri('/api/person/id')).toThrow()
+    expect(() => ModelsUtils.extractIdFromUri('/api/person/id')).toThrowError('id is not a number')
   })
 
   it('should return the id s uri', () => {

+ 3 - 3
tests/unit/services/utils/objectProperties.spec.ts

@@ -3,7 +3,7 @@ import { AnyJson } from '~/types/interfaces'
 
 describe('cloneAndFlatten()', () => {
   it('should throw an error if args is not an object', () =>
-    expect(() => $objectProperties.cloneAndFlatten(String as AnyJson)).toThrow()
+    expect(() => $objectProperties.cloneAndFlatten(String as AnyJson)).toThrowError('Expecting an object parameter')
   )
 
   it('should return same values for flat objects', () =>
@@ -39,7 +39,7 @@ describe('cloneAndFlatten()', () => {
 
 describe('cloneAndNest()', () => {
   it('should throw an error if args is not an object', () =>
-    expect(() => $objectProperties.cloneAndNest(String as AnyJson)).toThrow()
+    expect(() => $objectProperties.cloneAndNest(String as AnyJson)).toThrowError('Expecting an object parameter')
   )
 
   it('should return same values for flat objects', () =>
@@ -65,7 +65,7 @@ describe('cloneAndNest()', () => {
 
 describe('sortObjectByKey()', () => {
   it('should throw an error if args is not an array', () =>
-    expect(() => $objectProperties.sortObjectByKey('foo')).toThrow()
+    expect(() => $objectProperties.sortObjectByKey('foo')).toThrowError('Expecting an object parameter')
   )
   it('should sort an array by his keys', () =>
     expect($objectProperties.sortObjectByKey({ b: 1, d: 2, c: 3, a: 4 })).toStrictEqual({ a: 4, b: 1, c: 3, d: 2 })