Skip to content

Commit

Permalink
adobe#186 rename test file to match method
Browse files Browse the repository at this point in the history
  • Loading branch information
easingthemes committed Mar 6, 2022
1 parent c1da4ca commit ab3dc13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generators/add-action/aem-headless-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AemHeadlessClientGenerator extends ActionGenerator {
this.sourceRoot(path.join(__dirname, '.'))

this.addAction(this.props.actionName, '../../common-templates/stub-action.js', {
testFile: './templates/runQuery.test.js',
testFile: './templates/listPersistedQueries.test.js',
sharedLibFile: '../../common-templates/utils.js',
sharedLibTestFile: '../../common-templates/utils.test.js',
e2eTestFile: '../../common-templates/stub-action.e2e.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jest.mock('@adobe/aem-headless-client-nodejs', () => ({
}))
const { Core } = require('@adobe/aio-sdk')
const { AEMHeadless } = require('@adobe/aem-headless-client-nodejs')
const mockRunQueryInstance = { runQuery: jest.fn() }
const mockListPersistedQueriesInstance = { listPersistedQueries: jest.fn() }
const mockLoggerInstance = { info: jest.fn(), debug: jest.fn(), error: jest.fn() }
Core.Logger.mockReturnValue(mockLoggerInstance)
const sdk = new AEMHeadless.mockResolvedValue(mockRunQueryInstance)
const sdk = new AEMHeadless.mockResolvedValue(mockListPersistedQueriesInstance)

const action = require('./<%= actionRelPath %>')

beforeEach(() => {
sdk.runQuery.mockReset() // clears calls + mock implementation
sdk.listPersistedQueries.mockReset() // clears calls + mock implementation

Core.Logger.mockClear()
mockLoggerInstance.info.mockReset()
Expand All @@ -49,7 +49,7 @@ describe('<%= actionName %>', () => {
})
test('should return an http response with AEMHeadless results', async () => {
const fakeResponse = { fakeHash: {} }
sdk.runQuery.mockResolvedValue(fakeResponse)
sdk.listPersistedQueries.mockResolvedValue(fakeResponse)
const response = await action.main(fakeRequestParams)
expect(response).toEqual({
statusCode: 200,
Expand All @@ -58,7 +58,7 @@ describe('<%= actionName %>', () => {
})
test('if there is an error should return a 500 and log the error', async () => {
const fakeError = new Error('fake')
sdk.runQuery.mockRejectedValue(fakeError)
sdk.listPersistedQueries.mockRejectedValue(fakeError)
const response = await action.main(fakeRequestParams)
expect(response).toEqual({
error: {
Expand Down

0 comments on commit ab3dc13

Please sign in to comment.