]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
chore: improve coverage
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 8 Mar 2021 13:19:06 +0000 (14:19 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 8 Mar 2021 14:50:09 +0000 (15:50 +0100)
jest.config.js
src/rootStore.ts

index 05e74d0696bdbabdbf6274743ec116b1fcf62d87..971699f2746e218fdfa206680cec71b223e72fc7 100644 (file)
@@ -1,7 +1,13 @@
 module.exports = {
   preset: 'ts-jest',
   collectCoverage: true,
-  collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!<rootDir>/src/devtools.ts'],
+  collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
+  coveragePathIgnorePatterns: [
+    '/node_modules/',
+    'src/index.ts',
+    'src/devtools.ts',
+    'src/deprecated.ts',
+  ],
   testMatch: ['<rootDir>/__tests__/**/*.spec.ts'],
   setupFilesAfterEnv: ['./__tests__/setup.ts'],
   globals: {
index ced540100102129a0d632a6e8e0bbb835421bb04..322146e96c91d522a1f926fd42afdd2c4e52d25f 100644 (file)
@@ -22,7 +22,8 @@ export interface PiniaCustomProperties {}
 
 export const piniaSymbol = (__DEV__
   ? Symbol('pinia')
-  : Symbol()) as InjectionKey<Pinia>
+  : /* istanbul ignore next */
+    Symbol()) as InjectionKey<Pinia>
 
 /**
  * Plugin to extend every store
@@ -87,6 +88,7 @@ export const PiniaPlugin: PluginFunction<void> = 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` +