Skip to content

Commit

Permalink
fix: fix singleton spec
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Dec 20, 2023
1 parent 8c5f63e commit 5c617a8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 32 deletions.
10 changes: 6 additions & 4 deletions gen/templates/spec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ describe('##__RESOURCE_CLASS__## resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/api_credentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ describe('ApiCredentials resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/application_memberships.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ describe('ApplicationMemberships resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/memberships.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ describe('Memberships resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/organizations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ describe('Organizations resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ describe('Permissions resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/roles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ describe('Roles resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
10 changes: 6 additions & 4 deletions specs/resources/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ describe('Users resource', () => {
const resData = { id: TestData.id, ...attributes}

const intId = clp.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
if (config.method !== 'get') {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
}
return interceptRequest()
})

await clp[resourceType].update(resData, params, CommonData.options)
Expand Down
4 changes: 4 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@







import type { Resource, ResourceRel } from './resource'
import type { VersionType } from './resources/versions'

Expand Down

0 comments on commit 5c617a8

Please sign in to comment.