Skip to content

Commit d00c3fb

Browse files
Merge pull request #43 from webdevnerdstuff/vitest
Vitest
2 parents 07c6af3 + da6b820 commit d00c3fb

36 files changed

+2081
-201
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trim_trailing_whitespace = false
1414
[*.{yml,yaml}]
1515
indent_size = 2
1616

17-
[*.{js,ts,vue}]
17+
[*.{js,ts,mts,vue}]
1818
indent_size = 2
1919
indent_style = tab
2020

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged && npm run test:commit

dist/plugin/VCodeBlock.vue.d.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,44 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
6060
onRun?: ((...args: any[]) => any) | undefined;
6161
"onUpdate:copy-status"?: ((...args: any[]) => any) | undefined;
6262
}, {
63-
persistentCopyButton: boolean;
6463
highlightjs: boolean;
65-
floatingTabs: boolean;
66-
tabGap: string | number;
67-
copyTab: boolean;
68-
height: string | number;
69-
maxHeight: string | number;
70-
codeBlockRadius: string;
71-
runTab: boolean;
72-
tabs: boolean;
64+
prismjs: boolean;
7365
browserWindow: boolean;
7466
cssPath: string;
7567
code: string | number | object | [];
68+
codeBlockRadius: string;
7669
copyButton: boolean;
7770
copyIcons: boolean;
71+
copyTab: boolean;
7872
copyFailedText: string;
7973
copyText: string;
8074
copySuccessText: string;
75+
floatingTabs: boolean;
76+
height: string | number;
8177
indent: number;
8278
label: string;
8379
lang: string;
84-
prismjs: boolean;
80+
maxHeight: string | number;
81+
persistentCopyButton: boolean;
8582
prismPlugin: boolean;
83+
runTab: boolean;
8684
runText: string;
85+
tabGap: string | number;
86+
tabs: boolean;
8787
theme: string | boolean;
8888
}, {}>, {
8989
label?(_: {
9090
copyCode: typeof copyCode;
91-
copyStatus: string;
91+
copyStatus: "copy" | "success" | "failed";
9292
runCode: typeof runCode;
9393
}): any;
9494
tabs?(_: {
9595
copyCode: typeof copyCode;
96-
copyStatus: string;
96+
copyStatus: "copy" | "success" | "failed";
9797
runCode: typeof runCode;
9898
}): any;
9999
copyButton?(_: {
100-
copyStatus: string;
100+
copyStatus: "copy" | "success" | "failed";
101101
}): any;
102102
}>;
103103
export default _default;

dist/plugin/composables/helpers.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
import { UseConvertToUnit } from '../../plugin/types';
12
/**
23
* Converts a string to a number with a unit.
34
*/
4-
export declare function useConvertToUnit(str: string | number | undefined | null, unit?: string): string | void;
5+
export declare const useConvertToUnit: UseConvertToUnit;

dist/plugin/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { App } from 'vue';
22
import type { Props } from './types';
33
import VCodeBlock from './VCodeBlock.vue';
44
export declare const codeBlockOptions: unique symbol;
5-
export declare function createVCodeBlock(options?: Props): (app: App) => void;
5+
export declare function createVCodeBlock(options?: Props): {
6+
install: (app: App) => void;
7+
};
68
export default VCodeBlock;
79
export { VCodeBlock, };

dist/plugin/types/index.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CSSProperties, MaybeRef } from 'vue';
22
import VCodeBlock from '../VCodeBlock.vue';
33
export * from '../index';
44
export type UseTheme = MaybeRef<string | boolean>;
5+
export type CopyStatus = MaybeRef<'copy' | 'success' | 'failed'>;
56
export interface Props {
67
browserWindow?: boolean;
78
cssPath?: string | undefined;
@@ -31,6 +32,12 @@ export interface Props {
3132
tabs?: boolean;
3233
theme?: string | boolean;
3334
}
35+
export interface UseConvertToUnit {
36+
(options: {
37+
str: string | number | undefined | null;
38+
unit?: string;
39+
}): string | void;
40+
}
3441
export interface UseCodeBlockClasses {
3542
(options: {
3643
isMobile: MaybeRef<boolean>;
@@ -39,14 +46,14 @@ export interface UseCodeBlockClasses {
3946
}
4047
export interface UseCopyButtonClasses {
4148
(options: {
42-
copyStatus: MaybeRef<string>;
49+
copyStatus: CopyStatus;
4350
isMobile: MaybeRef<boolean>;
4451
persistentCopyButton: MaybeRef<Props['persistentCopyButton']>;
4552
}): object;
4653
}
4754
export interface UseIconClasses {
4855
(options: {
49-
copyStatus: MaybeRef<string>;
56+
copyStatus: CopyStatus;
5057
highlightjs: MaybeRef<Props['highlightjs']>;
5158
useTheme: UseTheme;
5259
}): object;

dist/vue-code-block.cjs.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-code-block.es.js

Lines changed: 129 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515
"play": "sh src/playground/configs/build.sh && NODE_ENV=playground vite",
1616
"sass": "sass --watch --no-source-map src/plugin/themes/scss/:src/plugin/themes/css",
1717
"sass:min": "sass --style compressed --watch --no-source-map src/plugin/themes/scss/:src/plugin/themes/css/min",
18-
"build": "vue-tsc && vite build --config vite.build.config.ts",
18+
"build": "vue-tsc -p tsconfig.dist.json && npm run test:build && vite build --config vite.build.config.mts",
1919
"build:docs": "vite build",
2020
"predeploy": "npm run build",
2121
"deploy": "gh-pages -d docs",
2222
"prepublishOnly": "npm run build",
2323
"lint": "eslint src/**/*.{ts,vue} --max-warnings 4",
24-
"prepare": "husky install"
24+
"prepare": "husky install",
25+
"test": "vitest",
26+
"test:commit": "vitest --run --bail 1",
27+
"test:build": "vitest --run --bail 1 --reporter dot"
2528
},
2629
"lint-staged": {
2730
"src/**/*.{js,ts,vue}": [
@@ -94,6 +97,7 @@
9497
"@vue/cli-service": "^5.0.8",
9598
"@vue/compiler-sfc": "^3.3.9",
9699
"@vue/eslint-config-typescript": "^12.0.0",
100+
"@vue/test-utils": "^2.4.3",
97101
"autoprefixer": "^10.4.16",
98102
"eslint": "^8.55.0",
99103
"eslint-config-prettier": "^9.1.0",
@@ -102,6 +106,7 @@
102106
"eslint-plugin-vue": "^9.19.2",
103107
"gh-pages": "^6.1.0",
104108
"husky": "^8.0.3",
109+
"jsdom": "^23.0.1",
105110
"lint-staged": "^15.0.2",
106111
"pinia": "^2.1.7",
107112
"postcss": "^8.4.32",
@@ -119,13 +124,14 @@
119124
"stylelint-scss": "^5.3.1",
120125
"typescript": "^5.3.2",
121126
"unplugin-auto-import": "^0.17.1",
122-
"vite": "^4.5.0",
127+
"vite": "^4.5.1",
123128
"vite-plugin-css-injected-by-js": "^3.3.0",
124129
"vite-plugin-dts": "^3.6.4",
125130
"vite-plugin-eslint": "^1.8.1",
126131
"vite-plugin-static-copy": "^0.17.0",
127132
"vite-plugin-stylelint": "^5.2.1",
128133
"vite-plugin-vuetify": "^1.0.2",
134+
"vitest": "^1.0.4",
129135
"vue-tsc": "^1.8.24",
130136
"vuetify": "^3.4.4",
131137
"webfontloader": "^1.6.28"

0 commit comments

Comments
 (0)