Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 327578d

Browse files
committed
feat(helper and core/method): add and change isDevelopOrTest variable.
1 parent e651bbb commit 327578d

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/_internal/utils/helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as path from 'path';
55
export const isWindowDefined = typeof window !== 'undefined';
66
export const isDocumentDefined = typeof document !== 'undefined';
77
export const isInDevelopment = process.env.NODE_ENV === 'development';
8+
export const isDevelopAndTest = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
89

910
const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index'];
1011

src/core/method/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ReturnStyleType, ClassesObjectType, ExactClassesObjectType } from '../../_internal';
2-
import { sheetCompiler, isInDevelopment, injectCSS, genBase62Hash } from '../../_internal';
2+
import { isInDevelopment, isDevelopAndTest, injectCSS, sheetCompiler, genBase62Hash } from '../../_internal';
33
import styles from '../styles/style.module.css';
44
import { createGlobalStyleSheetPromise, globalStyleSheetPromise, resolveGlobalStyleSheet } from './create-build-in-helper';
55

@@ -14,7 +14,7 @@ export function create<T extends ClassesObjectType>(object: ExactClassesObjectTy
1414
if (typeof prop === 'string' && prop in target) {
1515
const className = prop + '_' + base62Hash;
1616
if (isInDevelopment) injectCSS(base62Hash, styleSheet, 'create');
17-
return isInDevelopment ? className : styles[className];
17+
return isDevelopAndTest ? className : styles[className];
1818
}
1919
},
2020
}) as unknown as ReturnStyleType<T>;

src/core/method/global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { CustomHTMLType } from '../../_internal';
2-
import { isInDevelopment, injectCSSGlobal, sheetCompiler } from '../../_internal';
2+
import { isDevelopAndTest, injectCSSGlobal, sheetCompiler } from '../../_internal';
33
import { resolveGlobalStyleSheet, globalStyleSheetPromise, createGlobalStyleSheetPromise } from './global-build-in-helper';
44

55
export function global(object: CustomHTMLType): void {
66
const { styleSheet } = sheetCompiler(object, undefined, '--global');
77
if (typeof globalStyleSheetPromise === 'undefined') createGlobalStyleSheetPromise();
88
resolveGlobalStyleSheet([styleSheet, '--global']);
99

10-
if (isInDevelopment) injectCSSGlobal(styleSheet, 'global');
10+
if (isDevelopAndTest) injectCSSGlobal(styleSheet, 'global');
1111
}

src/core/method/root.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { ExtendedCSSProperties } from '../../_internal';
2-
import { isInDevelopment, injectCSSGlobal, styleCompiler } from '../../_internal';
2+
import { isDevelopAndTest, injectCSSGlobal, styleCompiler } from '../../_internal';
33
import { resolveGlobalStyleSheet, globalStyleSheetPromise, createGlobalStyleSheetPromise } from './root-build-in-helper';
44

55
export function root(object: ExtendedCSSProperties): void {
66
const { styleSheet } = styleCompiler(object, undefined, '--root');
77
if (typeof globalStyleSheetPromise === 'undefined') createGlobalStyleSheetPromise();
88
resolveGlobalStyleSheet([styleSheet, '--global']);
99

10-
if (isInDevelopment) injectCSSGlobal(styleSheet, 'root');
10+
if (isDevelopAndTest) injectCSSGlobal(styleSheet, 'root');
1111
}

src/core/method/set.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ExtendedCSSProperties } from '../../_internal';
2-
import { isInDevelopment, injectCSS, styleCompiler, genBase62Hash } from '../../_internal';
2+
import { isInDevelopment, isDevelopAndTest, injectCSS, styleCompiler, genBase62Hash } from '../../_internal';
33
import styles from '../styles/style.module.css';
44
import { createGlobalStyleSheetPromise, globalStyleSheetPromise, resolveGlobalStyleSheet } from './set-build-in-helper';
55

@@ -12,7 +12,7 @@ export function set(object: ExtendedCSSProperties): string {
1212

1313
function returnFunction() {
1414
if (isInDevelopment) injectCSS(base62Hash, styleSheet, 'set');
15-
return isInDevelopment ? classHash : styles[classHash];
15+
return isDevelopAndTest ? classHash : styles[classHash];
1616
}
1717

1818
return returnFunction() as unknown as string;

0 commit comments

Comments
 (0)