Skip to content

Commit

Permalink
chore(#693): update druxt-menu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Aug 13, 2024
1 parent deedb4d commit c8f524f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/menu/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addPluginTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import { join, resolve } from 'path'
// import DruxtMenuStorybook from '../nuxtStorybook'
// import DruxtMenuStorybook from './storybook'

/**
* The Nuxt.js module function.
Expand Down
File renamed without changes.
44 changes: 44 additions & 0 deletions packages/menu/test/nuxt/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import DruxtMenuNuxtModule from '../../src/nuxt'

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

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])
}),
}

test('Nuxt module', async () => {
// Use module with defaults.
await DruxtMenuNuxtModule.setup({}, nuxtMock)
expect(addPluginTemplate).toHaveBeenCalled()

// Expect JSON:API Menu Items tp be enabled.
expect(installModule).toHaveBeenLastCalledWith('druxt/nuxt', {
baseUrl: undefined,
menu: {
jsonApiMenuItems: true
}
})

// Use overridden options; Drupal content menu items.
await DruxtMenuNuxtModule.setup({}, { ...nuxtMock, options: { druxt: { menu: { jsonApiMenuItems: false }}} })
expect(installModule).toHaveBeenLastCalledWith('druxt/nuxt', {
baseUrl: undefined,
menu: {
jsonApiMenuItems: false
}
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DruxtMenuStorybook from '../src/nuxtStorybook'
import DruxtMenuStorybook from '../../src/nuxt/storybook'

jest.mock('axios')

Expand Down
43 changes: 0 additions & 43 deletions packages/menu/test/nuxtModule.test.js

This file was deleted.

0 comments on commit c8f524f

Please sign in to comment.