modelsUtils.spec.ts 495 B

123456789101112131415
  1. import ModelsUtils from "~/services/utils/modelsUtils";
  2. describe('extractIdFromUri()', () => {
  3. it('should return null if uri is empty', () => {
  4. expect(ModelsUtils.extractIdFromUri('')).toBeNull()
  5. })
  6. it('should return Error if uri is not an number', () => {
  7. expect(() => ModelsUtils.extractIdFromUri('/api/person/id')).toThrowError('id is not a number')
  8. })
  9. it('should return the id s uri', () => {
  10. expect(ModelsUtils.extractIdFromUri('/api/person/2')).toEqual(2)
  11. })
  12. })