Skip to content

Commit c36fdd5

Browse files
committed
test: fix tests
1 parent ae99b02 commit c36fdd5

File tree

9 files changed

+1550
-44
lines changed

9 files changed

+1550
-44
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
# JS and TS files must always use LF for tools to work
55
*.js eol=lf
66
*.ts eol=lf
7-
angular-html-parser/**/* eol.lf
7+
8+
# angular-html-parser
9+
packages/angular-html-parser/**/* eol.lf

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ baseline.json
5656

5757
# Ignore cache created with the Angular CLI.
5858
.angular/
59+
60+
# angular-html-parser
61+
packages/angular-html-parser/coverage
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.yarn/
22
lib/
3+
coverage/

packages/angular-html-parser/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@
2323
"clean": "del-cli ./lib",
2424
"build-lib": "tsc -p tsconfig.build.json",
2525
"codemod": "node ./node_modules/jscodeshift/bin/jscodeshift.js -t postbuild-codemod.ts lib --extensions=js,ts --parser=ts",
26-
"test": "ts-node --project tsconfig.test.json -r tsconfig-paths/register node_modules/jasmine/bin/jasmine.js ../compiler/test/ml_parser/*_spec.ts ./test/*_spec.ts",
26+
"test": "vitest",
2727
"release": "standard-version",
2828
"fix": "prettier . --write"
2929
},
3030
"devDependencies": {
31+
"@types/node": "22.13.10",
32+
"@vitest/coverage-v8": "3.0.8",
3133
"del-cli": "6.0.0",
3234
"jasmine": "5.6.0",
3335
"jscodeshift": "17.1.2",
3436
"prettier": "3.5.3",
3537
"standard-version": "9.5.0",
3638
"ts-node": "10.9.2",
3739
"tsconfig-paths": "4.2.0",
38-
"typescript": "5.8.2"
40+
"typescript": "5.8.2",
41+
"vitest": "3.0.8"
3942
},
4043
"engines": {
4144
"node": ">= 14"

packages/angular-html-parser/postbuild-codemod.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import {API, FileInfo} from 'jscodeshift';
1+
import { API, FileInfo } from "jscodeshift";
22

33
export default function transformer(file: FileInfo, api: API) {
44
const j = api.jscodeshift;
55

66
const ast = j(file.source);
77

8-
ast.find(j.ImportDeclaration).forEach(({node}) => {
8+
ast.find(j.ImportDeclaration).forEach(({ node }) => {
99
const source = node.source.value as string;
10-
if (!source.endsWith('.js')) {
11-
node.source.value = source + '.js';
10+
if (!source.endsWith(".js")) {
11+
node.source.value = source + ".js";
1212
}
1313
});
1414

15-
ast.find(j.TSTypeAliasDeclaration).forEach(({node}) => {
16-
if (node.id.name === 'Node' && node.typeAnnotation.type === 'TSUnionType') {
15+
ast.find(j.TSTypeAliasDeclaration).forEach(({ node }) => {
16+
if (node.id.name === "Node" && node.typeAnnotation.type === "TSUnionType") {
1717
node.typeAnnotation.types = node.typeAnnotation.types.filter(
1818
(type) =>
19-
type.type === 'TSTypeReference' &&
20-
type.typeName.type === 'Identifier' &&
21-
type.typeName.name !== 'Expansion' &&
22-
type.typeName.name !== 'ExpansionCase'
19+
type.type === "TSTypeReference" &&
20+
type.typeName.type === "Identifier" &&
21+
type.typeName.name !== "Expansion" &&
22+
type.typeName.name !== "ExpansionCase",
2323
);
2424
}
2525
});

packages/angular-html-parser/test/index_spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,41 +56,41 @@ describe("AST format", () => {
5656
const input = `<!DOCTYPE html> <el attr></el>txt<!-- --><![CDATA[foo]]>`;
5757
const ast = parse(input);
5858
expect(ast.rootNodes).toEqual([
59-
jasmine.objectContaining({ type: "docType" }),
60-
jasmine.objectContaining({ type: "text" }),
61-
jasmine.objectContaining({
59+
expect.objectContaining({ type: "docType" }),
60+
expect.objectContaining({ type: "text" }),
61+
expect.objectContaining({
6262
type: "element",
63-
attrs: [jasmine.objectContaining({ type: "attribute" })],
63+
attrs: [expect.objectContaining({ type: "attribute" })],
6464
}),
65-
jasmine.objectContaining({ type: "text" }),
66-
jasmine.objectContaining({ type: "comment" }),
67-
jasmine.objectContaining({ type: "cdata" }),
65+
expect.objectContaining({ type: "text" }),
66+
expect.objectContaining({ type: "comment" }),
67+
expect.objectContaining({ type: "cdata" }),
6868
]);
6969
});
7070

7171
it("should have `type` property when tokenizeBlocks is enabled", () => {
7272
const input = `@if (user.isHuman) { <p>Hello human</p> }`;
7373
const ast = parse(input, { tokenizeAngularBlocks: true });
7474
expect(ast.rootNodes).toEqual([
75-
jasmine.objectContaining({
75+
expect.objectContaining({
7676
name: "if",
7777
type: "block",
7878
parameters: [
79-
jasmine.objectContaining({
79+
expect.objectContaining({
8080
type: "blockParameter",
8181
expression: "user.isHuman",
8282
}),
8383
],
8484
children: [
85-
jasmine.objectContaining({ type: "text", value: " " }),
86-
jasmine.objectContaining({
85+
expect.objectContaining({ type: "text", value: " " }),
86+
expect.objectContaining({
8787
type: "element",
8888
name: "p",
8989
children: [
90-
jasmine.objectContaining({ type: "text", value: "Hello human" }),
90+
expect.objectContaining({ type: "text", value: "Hello human" }),
9191
],
9292
}),
93-
jasmine.objectContaining({ type: "text", value: " " }),
93+
expect.objectContaining({ type: "text", value: " " }),
9494
],
9595
}),
9696
]);

packages/angular-html-parser/tsconfig.test.json renamed to packages/angular-html-parser/tsconfig.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77
"rewriteRelativeImportExtensions": true,
88
"paths": {
99
"@angular/*": ["../*"]
10-
}
11-
},
12-
"ts-node": {
13-
"transpileOnly": true,
14-
"experimentalResolver": true,
15-
"moduleTypes": {
16-
"**/*.ts": "cjs"
17-
}
10+
},
11+
"types": ["vitest/globals"]
1812
}
1913
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
include: [
7+
// "../compiler/test/ml_parser/*_spec.ts",
8+
"./test/*_spec.ts",
9+
],
10+
coverage: {
11+
enabled: Boolean(process.env.CI),
12+
provider: "v8",
13+
reporter: ["lcov", "text"],
14+
include: ["src/**/*.ts"],
15+
},
16+
},
17+
});

0 commit comments

Comments
 (0)