Skip to content

Commit

Permalink
Add unit tests for UI extension space methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnagara committed Aug 28, 2017
1 parent 24ff1c1 commit 69e658d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
60 changes: 59 additions & 1 deletion test/unit/create-space-api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
roleMock,
apiKeyMock,
setupEntitiesMock,
cloneMock
cloneMock,
uiExtensionMock
} from './mocks/entities'
import setupHttpMock from './mocks/http'
import {
Expand Down Expand Up @@ -682,3 +683,60 @@ test('API call createApiKeyWithId fails', (t) => {
methodToTest: 'createApiKeyWithId'
})
})

test('API call getUiExtension', (t) => {
makeGetEntityTest(t, setup, teardown, {
entityType: 'uiExtension',
mockToReturn: uiExtensionMock,
methodToTest: 'getUiExtension'
})
})

test('API call getUiExtension fails', (t) => {
makeEntityMethodFailingTest(t, setup, teardown, {
methodToTest: 'getUiExtension'
})
})

test('API call getUiExtensions', (t) => {
makeGetCollectionTest(t, setup, teardown, {
entityType: 'uiExtension',
mockToReturn: uiExtensionMock,
methodToTest: 'getUiExtensions'
})
})

test('API call getUiExtensions fails', (t) => {
makeEntityMethodFailingTest(t, setup, teardown, {
methodToTest: 'getUiExtensions'
})
})

test('API call createUiExtension', (t) => {
makeEntityMethodFailingTest(t, setup, teardown, {
entityType: 'uiExtension',
mockToReturn: uiExtensionMock,
methodToTest: 'createUiExtension'
})
})

test('API call createUiExtension fails', (t) => {
makeEntityMethodFailingTest(t, setup, teardown, {
methodToTest: 'createUiExtension'
})
})

test('API call createUiExtensionWithId', (t) => {
makeCreateEntityWithIdTest(t, setup, teardown, {
entityType: 'uiExtension',
mockToReturn: uiExtensionMock,
methodToTest: 'createUiExtensionWithId',
entityPath: 'extensions'
})
})

test('API call createUiExtensionWithId fails', (t) => {
makeEntityMethodFailingTest(t, setup, teardown, {
methodToTest: 'createUiExtensionWithId'
})
})
4 changes: 2 additions & 2 deletions test/unit/mocks/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ function setupEntitiesMock (rewiredModuleApi) {
wrapOrganizationCollection: sinon.stub()
},
uiExtension: {
wrapLocale: sinon.stub(),
wrapLocaleCollection: sinon.stub()
wrapUiExtension: sinon.stub(),
wrapUiExtensionCollection: sinon.stub()
}
}
rewiredModuleApi.__Rewire__('entities', entitiesMock)
Expand Down

0 comments on commit 69e658d

Please sign in to comment.