Skip to content

Commit

Permalink
chore(#693): fix storybook unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Sep 2, 2024
1 parent 7fa1ef9 commit 42bd94f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
2 changes: 0 additions & 2 deletions packages/blocks/test/nuxt/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ jest.mock('axios')

jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
defineNuxtModule: (module) => module,
}))

const mock = {
addTemplate: jest.fn(),
options: {
buildDir: '',
druxt: {
Expand Down
1 change: 1 addition & 0 deletions packages/breadcrumb/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import DruxtBreadcrumbModule from '../../src/nuxt'

jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
defineNuxtModule: (module) => module,
installModule: jest.fn(),
}))
Expand Down
5 changes: 4 additions & 1 deletion packages/entity/test/nuxt/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import DruxtEntityStorybook from '../../src/nuxt/storybook'

jest.mock('axios')

const mock = {
jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
}))

const mock = {
options: {
buildDir: '',
druxt: {
Expand Down
5 changes: 4 additions & 1 deletion packages/menu/test/nuxt/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import DruxtMenuStorybook from '../../src/nuxt/storybook'

jest.mock('axios')

const mock = {
jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
}))

const mock = {
options: {
buildDir: '',
druxt: {
Expand Down
12 changes: 6 additions & 6 deletions packages/router/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ test('Nuxt module', async () => {
nuxtMock.options.druxt.router = { pages: true }
await DruxtRouterNuxtModule.setup({}, nuxtMock)
expect(addPluginTemplate).toHaveBeenCalledTimes(2)
expect(addTemplate).toHaveBeenCalledTimes(1)
expect(nuxtMock.hook).toHaveBeenCalledTimes(1)
expect(addTemplate).toHaveBeenCalledTimes(2)
expect(nuxtMock.hook).toHaveBeenCalledTimes(2)
jest.clearAllMocks()

nuxtMock.options.druxt.router = { wildcard: false }
await DruxtRouterNuxtModule.setup({}, nuxtMock)
expect(addPluginTemplate).toHaveBeenCalledTimes(2)
expect(addTemplate).toHaveBeenCalledTimes(0)
expect(nuxtMock.hook).toHaveBeenCalledTimes(1)
expect(addTemplate).toHaveBeenCalledTimes(1)
expect(nuxtMock.hook).toHaveBeenCalledTimes(2)
jest.clearAllMocks()

nuxtMock.options.druxt.router = { pages: false }
await DruxtRouterNuxtModule.setup({}, nuxtMock)
expect(addPluginTemplate).toHaveBeenCalledTimes(2)
expect(addTemplate).toHaveBeenCalledTimes(1)
expect(nuxtMock.hook).toHaveBeenCalledTimes(2)
expect(addTemplate).toHaveBeenCalledTimes(2)
expect(nuxtMock.hook).toHaveBeenCalledTimes(3)
expect(nuxtMock.options.build.createRoutes()).toStrictEqual([])
jest.clearAllMocks()
})
5 changes: 4 additions & 1 deletion packages/site/test/nuxt/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import DruxtEntityStorybook from '../../src/nuxt/storybook'

jest.mock('axios')

const mock = {
jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
}))

const mock = {
options: {
buildDir: '',
druxt: {
Expand Down
5 changes: 4 additions & 1 deletion packages/views/test/nuxt/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import DruxtEntityStorybook from '../../src/nuxt/storybook'

jest.mock('axios')

const mock = {
jest.mock('@nuxt/kit', () => ({
addTemplate: jest.fn(),
}))

const mock = {
options: {
buildDir: '',
druxt: {
Expand Down

0 comments on commit 42bd94f

Please sign in to comment.