Skip to content

Commit

Permalink
add vue2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhxx committed May 12, 2023
1 parent a7bcc7b commit aa7742b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion __tests__/capture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {describe, test, beforeEach, expect} from 'vitest';
import ClickThrow from './components/click.vue';
import Caputre from './components/capture.vue';
import ErrorBoundary, {ErrorBoundaryProps} from '@src';
import {defineComponent, h} from 'vue';
import {defineComponent, h} from 'vue-demi';

let App: any;

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/network.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang="ts">
import axios from 'axios';
import {reactive} from 'vue';
import {reactive} from 'vue-demi';
// eslint-disable-next-line no-undef
defineOptions({name: 'SuspenseWrapper'});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/emits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ErrorBoundary, {
import ClickThrow from './components/click.vue';
import Caputre from './components/capture.vue';
import {mount} from '@vue/test-utils';
import {defineComponent, h} from 'vue';
import {defineComponent, h} from 'vue-demi';
import {describe, test, expect} from 'vitest';

const App = defineComponent({
Expand All @@ -29,7 +29,7 @@ const App = defineComponent({
},
});

describe('ErrorBoundary emit value', async function () {
describe('ErrorBoundary emit value', function () {
test('should emit error', async function () {
const app = mount(App);

Expand Down
4 changes: 2 additions & 2 deletions __tests__/hook.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, test, beforeEach, expect} from 'vitest';
import HookTest from './components/hook.vue';
import ClickTest from './components/click.vue';
import {h, defineComponent} from 'vue';
import {h, defineComponent} from 'vue-demi';
import {mount} from '@vue/test-utils';
import ErrorBoundary from '@src';

Expand All @@ -28,7 +28,7 @@ describe('useBoundary hook', function () {
test('error info', async function () {
const app = mount(App);

let throwBtn = app.get('#throw');
const throwBtn = app.get('#throw');
await throwBtn.trigger('click');

const error = app.find('#error_info');
Expand Down
2 changes: 1 addition & 1 deletion __tests__/includeAndExclude.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Caputre from './components/capture.vue';
import ClickTypeError from './components/typeError.vue';
import ClickRefError from './components/refError.vue';
import {mount} from '@vue/test-utils';
import {defineComponent, h, onErrorCaptured} from 'vue';
import {defineComponent, h, onErrorCaptured} from 'vue-demi';
import {describe, test, beforeEach, expect} from 'vitest';

let App: any;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/propagation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ErrorBoundary, {ErrorBoundaryProps} from '@src';
import ClickThrow from './components/click.vue';
import Caputre from './components/capture.vue';
import {mount} from '@vue/test-utils';
import {defineComponent, h, onErrorCaptured} from 'vue';
import {defineComponent, h, onErrorCaptured} from 'vue-demi';
import {describe, test, beforeEach, expect, vi} from 'vitest';

const fn = vi.fn();
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ErrorBoundary, {ErrorBoundaryProps} from '@src';
import ClickThrow from './components/click.vue';
import Caputre from './components/capture.vue';
import {mount} from '@vue/test-utils';
import {defineComponent, h} from 'vue';
import {defineComponent, h} from 'vue-demi';
import {describe, test, expect} from 'vitest';

const App = defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/suspense.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ErrorBoundary, {ErrorBoundaryProps} from '@src';
import {mount, flushPromises} from '@vue/test-utils';
import {defineComponent, h, ref, Suspense} from 'vue';
import {defineComponent, h, ref, Suspense} from 'vue-demi';
import Caputre from './components/capture.vue';
import NetworkCom from './components/network.vue';
import {vi, describe, test, expect} from 'vitest';
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"build:es": "vite build --mode es",
"build": "pnpm build:ts && pnpm build:umd && pnpm build:es",
"test": "vitest",
"test:coverage": "vitest --coverage"
"test:coverage": "vitest --coverage",
"test:2": "vue-demi-switch 2 vue2 && vitest",
"test:3": "vue-demi-switch 3 && vitest"
},
"files": [
"dist"
Expand Down Expand Up @@ -59,7 +61,8 @@
"vitest": "^0.31.0",
"vue": "^3.3.2",
"vue-eslint-parser": "^9.2.1",
"vue-tsc": "^1.6.4"
"vue-tsc": "^1.6.4",
"vue2": "npm:vue@2"
},
"peerDependencies": {
"@vue/composition-api": ">=1.0.0",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aa7742b

Please sign in to comment.