test: improve coverage

This commit is contained in:
Evan You
2020-07-15 10:38:45 -04:00
parent 056a13142f
commit 32a4cb804b
7 changed files with 89 additions and 4 deletions

View File

@@ -2,10 +2,11 @@ import { warn, getCurrentInstance } from '@vue/runtime-core'
import { EMPTY_OBJ } from '@vue/shared'
export function useCssModule(name = '$style'): Record<string, string> {
/* istanbul ignore else */
if (!__GLOBAL__) {
const instance = getCurrentInstance()!
if (!instance) {
__DEV__ && warn(`useCSSModule must be called inside setup()`)
__DEV__ && warn(`useCssModule must be called inside setup()`)
return EMPTY_OBJ
}
const modules = instance.type.__cssModules
@@ -22,7 +23,7 @@ export function useCssModule(name = '$style'): Record<string, string> {
return mod as Record<string, string>
} else {
if (__DEV__) {
warn(`useCSSModule() is not supported in the global build.`)
warn(`useCssModule() is not supported in the global build.`)
}
return EMPTY_OBJ
}

View File

@@ -14,6 +14,7 @@ export function useCssVars(
scoped = false
) {
const instance = getCurrentInstance()
/* istanbul ignore next */
if (!instance) {
__DEV__ &&
warn(`useCssVars is called without current active component instance.`)