Skip to content

Commit

Permalink
chore(#693): updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Sep 19, 2024
1 parent 0828671 commit 34ada4d
Showing 1 changed file with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions packages/entity/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,55 @@ const nuxtMock = {
}),
}

test('Nuxt module', async () => {
nuxtMock.options = {
druxt: {},
modules: [],
}
await DruxtEntityNuxtModule.setup({}, nuxtMock)

expect(installModule).toHaveBeenCalledTimes(2)
expect(nuxtMock.hook).toHaveBeenCalledTimes(2)
describe('DruxtJS Nuxt module', () => {
beforeEach(() => jest.clearAllMocks())
test('Nuxt module', async () => {
nuxtMock.options = {
druxt: {},
modules: [],
}
await DruxtEntityNuxtModule.setup({}, nuxtMock)

expect(installModule).toHaveBeenCalledTimes(2)
expect(nuxtMock.hook).toHaveBeenCalledTimes(2)

// Find the hook function for 'components:dirs'
const componentsHooks = nuxtMock.hook.mock.calls.filter(call => call[0] === 'components:dirs')
expect(componentsHooks.length).toBe(1)

const componentDirs = []
// Execute the hook function to see what directories are added.
componentsHooks[0][1](componentDirs)

expect(componentDirs).toContainEqual({
path: expect.stringContaining('dist/components'),
ignore: ['fields'],
})
})

test('Nuxt module - components.fields true', async () => {
nuxtMock.options = {
druxt: {
entity: {
components: {
fields: true,
},
}
},
modules: [],
}
await DruxtEntityNuxtModule.setup({}, nuxtMock)

// Find the hook function for 'components:dirs'
const componentsHooks = nuxtMock.hook.mock.calls.filter(call => call[0] === 'components:dirs')
expect(componentsHooks.length).toBe(1)

const componentDirs = []
// Execute the hook function to see what directories are added.
componentsHooks[0][1](componentDirs)

expect(componentDirs).toContainEqual({
path: expect.stringContaining('dist/components/fields'),
})
})
})

0 comments on commit 34ada4d

Please sign in to comment.