Skip to content

Commit 04eec84

Browse files
committed
test: update test suite
1 parent 5098abd commit 04eec84

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

packages/nuxt-typed-vuex/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { name, version } from '../package.json'
77
/**
88
* @private
99
*/
10-
const nuxtTypedVuex: Module = async function() {
10+
const nuxtTypedVuex: Module = function nuxtTypedVuex() {
1111
const nuxtOptions = this.nuxt.options as NuxtOptions
1212

1313
if (!nuxtOptions.store) console.warn('You do not have a store defined.')

packages/nuxt-typed-vuex/test/fixture/store/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getAccessorType,
55
mutationTree,
66
actionTree,
7-
} from '../../../src'
7+
} from '../../../../typed-vuex/src'
88

99
import * as submodule from './submodule'
1010

packages/nuxt-typed-vuex/test/fixture/store/nuxt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { actionTree } from '../../../src'
1+
import { actionTree } from '../../../../typed-vuex/src'
22

33
export const state = () => ({
44
n: '',

packages/nuxt-typed-vuex/test/fixture/store/submodule.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { getterTree, mutationTree, actionTree, useAccessor } from '../../../src'
1+
import {
2+
getterTree,
3+
mutationTree,
4+
actionTree,
5+
useAccessor,
6+
} from '../../../../typed-vuex/src'
27
import { pattern } from '.'
38

49
export const state = () => ({
+9-19
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
import nuxtModule from '../src'
2-
import path from 'path'
2+
3+
import { setupTest, expectModuleToBeCalledWith } from '@nuxt/test-utils'
34

45
describe('nuxt module', () => {
6+
setupTest({
7+
testDir: __dirname,
8+
})
59
it('exists', () => {
610
expect(nuxtModule).toBeDefined()
711
})
8-
it('warns without store defined', () => {
9-
// @ts-ignore
10-
global.console = { warn: jest.fn() }
11-
const addPlugin = jest.fn()
12-
nuxtModule.call({
13-
options: {},
14-
addPlugin,
15-
})
16-
17-
expect(console.warn).toBeCalled()
18-
})
1912
it('adds plugin', () => {
20-
const addPlugin = jest.fn()
21-
nuxtModule.call({
13+
expectModuleToBeCalledWith('addPlugin', {
14+
src: expect.stringContaining('template/plugin.js'),
15+
fileName: 'nuxt-typed-vuex.js',
2216
options: {
23-
store: {},
17+
store: expect.stringContaining('store'),
2418
},
25-
addPlugin,
2619
})
27-
expect(addPlugin).toHaveBeenCalled()
28-
expect(addPlugin.mock.calls[0][0].options.store).toBeDefined()
29-
expect(path.resolve(addPlugin.mock.calls[0][0].src)).toBeDefined()
3020
})
3121
})

0 commit comments

Comments
 (0)