From 9ff5adea1cbf6b8e56c0e5220b3a1f2ec9420292 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Tue, 13 Aug 2024 10:28:36 +1000 Subject: [PATCH] chore(#693): update druxt-blocks tests --- packages/blocks/test/nuxt/index.test.js | 25 +++++++++++++++++++ .../storybook.test.js} | 7 +++++- packages/blocks/test/nuxtModule.test.js | 24 ------------------ 3 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 packages/blocks/test/nuxt/index.test.js rename packages/blocks/test/{nuxtStorybook.test.js => nuxt/storybook.test.js} (65%) delete mode 100644 packages/blocks/test/nuxtModule.test.js diff --git a/packages/blocks/test/nuxt/index.test.js b/packages/blocks/test/nuxt/index.test.js new file mode 100644 index 000000000..c4d8e37a7 --- /dev/null +++ b/packages/blocks/test/nuxt/index.test.js @@ -0,0 +1,25 @@ +import DruxtBlocksNuxtModule from '../../src/nuxt' + +// jest.mock('../src/nuxt/storybook') + +jest.mock('@nuxt/kit', () => ({ + defineNuxtModule: (module) => module, + installModule: jest.fn(), +})) + +const nuxtMock = { + hook: jest.fn((hook, fn) => { + const arg = { + 'components:dirs': [], + // 'storybook:config': { stories: [] } + } + return fn(arg[hook]) + }), +} + +test('Nuxt module', async () => { + nuxtMock.options = { + druxt: {} + } + await DruxtBlocksNuxtModule.setup({}, nuxtMock) +}) diff --git a/packages/blocks/test/nuxtStorybook.test.js b/packages/blocks/test/nuxt/storybook.test.js similarity index 65% rename from packages/blocks/test/nuxtStorybook.test.js rename to packages/blocks/test/nuxt/storybook.test.js index 593638cca..37ec0e57e 100644 --- a/packages/blocks/test/nuxtStorybook.test.js +++ b/packages/blocks/test/nuxt/storybook.test.js @@ -1,7 +1,12 @@ -import DruxtBlocksStorybook from '../src/nuxtStorybook' +import DruxtBlocksStorybook from '../../src/nuxt/storybook' jest.mock('axios') +jest.mock('@nuxt/kit', () => ({ + addTemplate: jest.fn(), + defineNuxtModule: (module) => module, +})) + const mock = { addTemplate: jest.fn(), options: { diff --git a/packages/blocks/test/nuxtModule.test.js b/packages/blocks/test/nuxtModule.test.js deleted file mode 100644 index 47e04540a..000000000 --- a/packages/blocks/test/nuxtModule.test.js +++ /dev/null @@ -1,24 +0,0 @@ -import { DruxtBlocksNuxtModule } from '../src/nuxtModule' - -jest.mock('../src/nuxtStorybook') - -const mock = { - addModule: jest.fn(), - nuxt: { - hook: jest.fn((hook, fn) => { - const arg = { - 'components:dirs': [], - 'storybook:config': { stories: [] } - } - return fn(arg[hook]) - }), - }, - DruxtBlocksNuxtModule -} - -test('Nuxt module', () => { - mock.options = { - druxt: {} - } - mock.DruxtBlocksNuxtModule() -})