Skip to content

Commit

Permalink
chore(#693): update druxt-views tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Aug 13, 2024
1 parent 1ffe6d7 commit f7fd989
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions packages/views/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { DruxtViewsNuxtModule } from '../../src/nuxt'
import DruxtViewsNuxtModule from '../../src/nuxt'

jest.mock('../../src/nuxt/storybook')

const mock = {
addModule: jest.fn(),
addPlugin: jest.fn(),
nuxt: {
hook: jest.fn((hook, fn) => {
const arg = {
'components:dirs': [],
'storybook:config': { stories: [] }
}
return fn(arg[hook])
}),
},
options: {
druxt: {},
modules: [],
},
jest.mock('@nuxt/kit', () => ({
addPluginTemplate: jest.fn(),
defineNuxtModule: (module) => module,
installModule: jest.fn(),
}))

import { addPluginTemplate, installModule } from '@nuxt/kit'

const nuxtMock = {
hook: jest.fn((hook, fn) => {
const arg = {
'components:dirs': [],
'storybook:config': { stories: [] }
}
return fn(arg[hook])
}),
options: {},
}

test('Nuxt module', async () => {
await DruxtViewsNuxtModule.call(mock)
expect(mock.addModule).toHaveBeenCalledTimes(3)
expect(mock.addPlugin).toHaveBeenCalledTimes(1)
await DruxtViewsNuxtModule.setup({}, nuxtMock)
expect(installModule).toHaveBeenCalledTimes(3)
expect(addPluginTemplate).toHaveBeenCalledTimes(1)
})

0 comments on commit f7fd989

Please sign in to comment.