From: Eduardo San Martin Morote Date: Mon, 8 Mar 2021 13:19:06 +0000 (+0100) Subject: chore: improve coverage X-Git-Tag: v0.2.0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32a49ca1ec792510e59af0dd8503560f878993e0;p=thirdparty%2Fvuejs%2Fpinia.git chore: improve coverage --- diff --git a/jest.config.js b/jest.config.js index 05e74d06..971699f2 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,13 @@ module.exports = { preset: 'ts-jest', collectCoverage: true, - collectCoverageFrom: ['/src/**/*.ts', '!/src/devtools.ts'], + collectCoverageFrom: ['/src/**/*.ts'], + coveragePathIgnorePatterns: [ + '/node_modules/', + 'src/index.ts', + 'src/devtools.ts', + 'src/deprecated.ts', + ], testMatch: ['/__tests__/**/*.spec.ts'], setupFilesAfterEnv: ['./__tests__/setup.ts'], globals: { diff --git a/src/rootStore.ts b/src/rootStore.ts index ced54010..322146e9 100644 --- a/src/rootStore.ts +++ b/src/rootStore.ts @@ -22,7 +22,8 @@ export interface PiniaCustomProperties {} export const piniaSymbol = (__DEV__ ? Symbol('pinia') - : Symbol()) as InjectionKey + : /* istanbul ignore next */ + Symbol()) as InjectionKey /** * Plugin to extend every store @@ -87,6 +88,7 @@ export const PiniaPlugin: PluginFunction = function (_Vue) { // installing pinia's plugin setActivePinia(options.pinia) // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L25 + /* istanbul ignore else */ if (!(this as any)._provided) { const provideCache = {} Object.defineProperty(this, '_provided', { @@ -120,6 +122,12 @@ export function createPinia(): Pinia { Vue: {} as any, use(plugin) { + /* istanbul ignore next */ + if (__DEV__) { + console.warn( + `[🍍]: The plugin API has plans to change to bring better extensibility. "pinia.use()" signature will change in the next release. It is recommended to avoid using this API.` + ) + } _p.push(plugin.bind(null, pinia)) }, @@ -143,13 +151,14 @@ export let activePinia: Pinia | undefined * * @param pinia - Pinia instance */ -export const setActivePinia = (pinia: Pinia | undefined) => +export const setActivePinia = (pinia: Pinia | undefined): Pinia | undefined => (activePinia = pinia) /** * Get the currently active pinia */ -export const getActivePinia = () => { +export const getActivePinia = (): Pinia => { + /* istanbul ignore if */ if (__DEV__ && !activePinia) { console.warn( `[🍍]: getActivePinia was called with no active Pinia. Did you forget to install pinia and inject it?\n\n` +