Skip to content

Commit

Permalink
test: shared vue-tsc test cases with vue2 (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk authored Oct 23, 2023
1 parent 5f2c029 commit 72798f0
Show file tree
Hide file tree
Showing 286 changed files with 278 additions and 327 deletions.
32 changes: 16 additions & 16 deletions packages/vue-component-meta/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createComponentMetaChecker, createComponentMetaCheckerByJsonConfig, Met
const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describe(`vue-component-meta ${withTsconfig ? 'with tsconfig' : 'without tsconfig'}`, () => {

test('empty-component', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/empty-component/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/empty-component/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.props.map(prop => prop.name)).toEqual([
Expand All @@ -20,7 +20,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('reference-type-props', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/reference-type-props/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/reference-type-props/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -341,7 +341,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('reference-type-props-js', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/reference-type-props/component-js.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/reference-type-props/component-js.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -385,7 +385,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('reference-type-props-js-setup', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/reference-type-props/component-js-setup.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/reference-type-props/component-js-setup.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -459,7 +459,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('reference-type-events', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/reference-type-events/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/reference-type-events/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -536,7 +536,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('template-slots', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/template-slots/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/template-slots/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -564,7 +564,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('template-slots without a script block', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/template-slots/component-no-script.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/template-slots/component-no-script.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -592,7 +592,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('class-slots', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/class-slots/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/class-slots/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand All @@ -611,7 +611,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('exposed', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/reference-type-exposed/component.vue');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/reference-type-exposed/component.vue');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand All @@ -626,7 +626,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('ts-component', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/ts-component/component.ts');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/ts-component/component.ts');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Function);
Expand All @@ -647,7 +647,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('ts-named-exports', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/ts-named-export/component.ts');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/ts-named-export/component.ts');
const exportNames = checker.getExportNames(componentPath);
const Foo = checker.getComponentMeta(componentPath, 'Foo');
const Bar = checker.getComponentMeta(componentPath, 'Bar');
Expand All @@ -673,7 +673,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ

test('options-api', () => {

const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/options-api/component.ts');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/options-api/component.ts');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Class);
Expand Down Expand Up @@ -727,14 +727,14 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
});

test('non-component', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/non-component/component.ts');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/non-component/component.ts');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Unknown);
});

test('ts-component.tsx', () => {
const componentPath = path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/ts-component/component.tsx');
const componentPath = path.resolve(__dirname, '../../../test-workspace/vue-component-meta/ts-component/component.tsx');
const meta = checker.getComponentMeta(componentPath);

expect(meta.type).toEqual(TypeMeta.Function);
Expand Down Expand Up @@ -762,11 +762,11 @@ const checkerOptions: MetaCheckerOptions = {
printer: { newLine: 1 },
};
const tsconfigChecker = createComponentMetaChecker(
path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta/tsconfig.json'),
path.resolve(__dirname, '../../../test-workspace/vue-component-meta/tsconfig.json'),
checkerOptions,
);
const noTsConfigChecker = createComponentMetaCheckerByJsonConfig(
path.resolve(__dirname, '../../vue-test-workspace/vue-component-meta'),
path.resolve(__dirname, '../../../test-workspace/vue-component-meta'),
{
"extends": "../tsconfig.json",
"include": [
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TextDocument } from 'vscode-languageserver-textdocument';
import * as fs from 'fs';
import type * as vscode from 'vscode-languageserver-protocol';

const baseDir = path.resolve(__dirname, '../../vue-test-workspace/complete');
const baseDir = path.resolve(__dirname, '../../../test-workspace/language-service/complete');
const testDirs = fs.readdirSync(baseDir);
const normalizeNewline = (text: string) => text.replace(/\r\n/g, '\n');

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/findDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tester } from './utils/createTester';
import { TextDocument } from 'vscode-languageserver-textdocument';
import * as fs from 'fs';

const baseDir = path.resolve(__dirname, '../../vue-test-workspace/find-definition');
const baseDir = path.resolve(__dirname, '../../../test-workspace/language-service/find-definition');
const testDirs = fs.readdirSync(baseDir);

for (const dirName of testDirs) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tester } from './utils/createTester';
import { TextDocument } from 'vscode-languageserver-textdocument';
import * as fs from 'fs';

const baseDir = path.resolve(__dirname, '../../vue-test-workspace/reference');
const baseDir = path.resolve(__dirname, '../../../test-workspace/language-service/reference');
const testDirs = fs.readdirSync(baseDir);

for (const dirName of testDirs) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tester } from './utils/createTester';
import { TextDocument } from 'vscode-languageserver-textdocument';
import * as fs from 'fs';

const baseDir = path.resolve(__dirname, '../../vue-test-workspace/rename');
const baseDir = path.resolve(__dirname, '../../../test-workspace/language-service/rename');
const testDirs = fs.readdirSync(baseDir);

for (const dirName of testDirs) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-service/tests/utils/createTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { resolveConfig } from '../../out';

const uriToFileName = (uri: string) => URI.parse(uri).fsPath.replace(/\\/g, '/');
const fileNameToUri = (fileName: string) => URI.file(fileName).toString();
const testRoot = path.resolve(__dirname, '../../../vue-test-workspace').replace(/\\/g, '/');
const testRoot = path.resolve(__dirname, '../../../../test-workspace/language-service').replace(/\\/g, '/');

export const rootUri = URI.file(testRoot);
export const tester = createTester(testRoot);
Expand Down
10 changes: 0 additions & 10 deletions packages/vue-test-workspace-vue-2/package.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions packages/vue-test-workspace-vue-2/vue-tsc/tsconfig.base.json

This file was deleted.

25 changes: 0 additions & 25 deletions packages/vue-test-workspace/tsconfig.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions packages/vue-test-workspace/vue-tsc/shared.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/vue-test-workspace/vue-tsc/tsconfig.base.json

This file was deleted.

Loading

0 comments on commit 72798f0

Please sign in to comment.