|
@@ -1,4 +1,4 @@
|
|
|
-import ConstructUrl from '~/services/connection/constructUrl'
|
|
|
|
|
|
|
+import UrlBuilder from '~/services/connection/urlBuilder'
|
|
|
import { QUERY_TYPE } from '~/types/enums'
|
|
import { QUERY_TYPE } from '~/types/enums'
|
|
|
import User from '~/tests/unit/fixture/models/User'
|
|
import User from '~/tests/unit/fixture/models/User'
|
|
|
import Organization from '~/tests/unit/fixture/models/Organization'
|
|
import Organization from '~/tests/unit/fixture/models/Organization'
|
|
@@ -7,13 +7,13 @@ import { repositoryHelper } from '~/services/store/repository'
|
|
|
describe('invoke()', () => {
|
|
describe('invoke()', () => {
|
|
|
describe('getDefaultUrl()', () => {
|
|
describe('getDefaultUrl()', () => {
|
|
|
it('should throw an error if URL is missing', () => {
|
|
it('should throw an error if URL is missing', () => {
|
|
|
- expect(() => ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(() => UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.DEFAULT
|
|
type: QUERY_TYPE.DEFAULT
|
|
|
})).toThrow()
|
|
})).toThrow()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the URL concat with Root URL', () => {
|
|
it('should return the URL concat with Root URL', () => {
|
|
|
- expect(ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.DEFAULT,
|
|
type: QUERY_TYPE.DEFAULT,
|
|
|
url: 'users'
|
|
url: 'users'
|
|
|
})).toEqual('/api/users')
|
|
})).toEqual('/api/users')
|
|
@@ -22,13 +22,13 @@ describe('invoke()', () => {
|
|
|
|
|
|
|
|
describe('getEnumUrl()', () => {
|
|
describe('getEnumUrl()', () => {
|
|
|
it('should throw an error if enumType is missing', () => {
|
|
it('should throw an error if enumType is missing', () => {
|
|
|
- expect(() => ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(() => UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.ENUM
|
|
type: QUERY_TYPE.ENUM
|
|
|
})).toThrow()
|
|
})).toThrow()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the Enum URL concat with Root URL', () => {
|
|
it('should return the Enum URL concat with Root URL', () => {
|
|
|
- expect(ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.ENUM,
|
|
type: QUERY_TYPE.ENUM,
|
|
|
enumType: 'billing_type'
|
|
enumType: 'billing_type'
|
|
|
})).toEqual('/api/enum/billing_type')
|
|
})).toEqual('/api/enum/billing_type')
|
|
@@ -37,7 +37,7 @@ describe('invoke()', () => {
|
|
|
|
|
|
|
|
describe('getModelUrl()', () => {
|
|
describe('getModelUrl()', () => {
|
|
|
it('should throw an error if model is missing', () => {
|
|
it('should throw an error if model is missing', () => {
|
|
|
- expect(() => ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(() => UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.MODEL
|
|
type: QUERY_TYPE.MODEL
|
|
|
})).toThrow()
|
|
})).toThrow()
|
|
|
})
|
|
})
|
|
@@ -46,7 +46,7 @@ describe('invoke()', () => {
|
|
|
const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
|
|
const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
|
|
|
repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
|
|
repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
|
|
|
|
|
|
|
|
- expect(ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.MODEL,
|
|
type: QUERY_TYPE.MODEL,
|
|
|
model: User
|
|
model: User
|
|
|
})).toEqual('/api/users')
|
|
})).toEqual('/api/users')
|
|
@@ -56,7 +56,7 @@ describe('invoke()', () => {
|
|
|
const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
|
|
const repositoryHelperMock = repositoryHelper as jest.Mocked<typeof repositoryHelper>
|
|
|
repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
|
|
repositoryHelperMock.getEntity = jest.fn().mockReturnValue('users')
|
|
|
|
|
|
|
|
- expect(() => ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(() => UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.MODEL,
|
|
type: QUERY_TYPE.MODEL,
|
|
|
model: User,
|
|
model: User,
|
|
|
rootModel: Organization
|
|
rootModel: Organization
|
|
@@ -69,7 +69,7 @@ describe('invoke()', () => {
|
|
|
.mockReturnValueOnce('users')
|
|
.mockReturnValueOnce('users')
|
|
|
.mockReturnValueOnce('organizations')
|
|
.mockReturnValueOnce('organizations')
|
|
|
|
|
|
|
|
- expect(ConstructUrl.invoke({
|
|
|
|
|
|
|
+ expect(UrlBuilder.invoke({
|
|
|
type: QUERY_TYPE.MODEL,
|
|
type: QUERY_TYPE.MODEL,
|
|
|
model: User,
|
|
model: User,
|
|
|
rootModel: Organization,
|
|
rootModel: Organization,
|