Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 33d298b

Browse files
committedDec 12, 2024
test(style-node-loc): added node types to tests
1 parent fd076a4 commit 33d298b

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed
 

‎tests/fixtures/parser/style-location-converter/simple-css-output.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
[
3+
"root",
34
{
45
"start": {
56
"line": 9,
@@ -16,6 +17,7 @@
1617
]
1718
],
1819
[
20+
"rule",
1921
{
2022
"start": {
2123
"line": 10,
@@ -32,6 +34,7 @@
3234
]
3335
],
3436
[
37+
"decl",
3538
{
3639
"start": {
3740
"line": 11,
@@ -48,6 +51,7 @@
4851
]
4952
],
5053
[
54+
"rule",
5155
{
5256
"start": {
5357
"line": 14,
@@ -64,6 +68,7 @@
6468
]
6569
],
6670
[
71+
"decl",
6772
{
6873
"start": {
6974
"line": 15,

‎tests/fixtures/parser/style-location-converter/simple-postcss-output.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
[
3+
"root",
34
{
45
"start": {
56
"line": 7,
@@ -16,6 +17,7 @@
1617
]
1718
],
1819
[
20+
"rule",
1921
{
2022
"start": {
2123
"line": 8,
@@ -32,6 +34,7 @@
3234
]
3335
],
3436
[
37+
"decl",
3538
{
3639
"start": {
3740
"line": 9,
@@ -48,6 +51,7 @@
4851
]
4952
],
5053
[
54+
"decl",
5155
{
5256
"start": {
5357
"line": 10,

‎tests/fixtures/parser/style-location-converter/simple-scss-output.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
[
3+
"root",
34
{
45
"start": {
56
"line": 7,
@@ -16,6 +17,7 @@
1617
]
1718
],
1819
[
20+
"rule",
1921
{
2022
"start": {
2123
"line": 8,
@@ -32,6 +34,7 @@
3234
]
3335
],
3436
[
37+
"rule",
3538
{
3639
"start": {
3740
"line": 9,
@@ -48,6 +51,7 @@
4851
]
4952
],
5053
[
54+
"comment",
5155
{
5256
"start": {
5357
"line": 10,
@@ -64,6 +68,7 @@
6468
]
6569
],
6670
[
71+
"decl",
6772
{
6873
"start": {
6974
"line": 11,
@@ -80,6 +85,7 @@
8085
]
8186
],
8287
[
88+
"rule",
8389
{
8490
"start": {
8591
"line": 14,
@@ -96,6 +102,7 @@
96102
]
97103
],
98104
[
105+
"decl",
99106
{
100107
"start": {
101108
"line": 15,

‎tests/src/parser/style-location-coverter.ts renamed to ‎tests/src/parser/style-location-converter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { generateParserOptions, listupFixtures } from "./test-utils.js";
88
import type { SourceLocation } from "../../../src/ast/common.js";
99

1010
const dirname = path.dirname(new URL(import.meta.url).pathname);
11-
const STYLE_CONTEXT_FIXTURE_ROOT = path.resolve(
11+
const STYLE_LOCATION_CONVERTER_FIXTURE_ROOT = path.resolve(
1212
dirname,
1313
"../../fixtures/parser/style-location-converter",
1414
);
@@ -24,7 +24,7 @@ describe("Check for AST.", () => {
2424
outputFileName,
2525
config,
2626
meetRequirements,
27-
} of listupFixtures(STYLE_CONTEXT_FIXTURE_ROOT)) {
27+
} of listupFixtures(STYLE_LOCATION_CONVERTER_FIXTURE_ROOT)) {
2828
describe(inputFileName, () => {
2929
let services: any;
3030

@@ -36,16 +36,19 @@ describe("Check for AST.", () => {
3636
const styleContext = services.getStyleContext();
3737
assert.strictEqual(styleContext.status, "success");
3838
const locations: [
39+
string,
3940
Partial<SourceLocation>,
4041
[number | undefined, number | undefined],
4142
][] = [
4243
[
44+
"root",
4345
services.styleNodeLoc(styleContext.sourceAst),
4446
services.styleNodeRange(styleContext.sourceAst),
4547
],
4648
];
4749
styleContext.sourceAst.walk((node: Node) => {
4850
locations.push([
51+
node.type,
4952
services.styleNodeLoc(node),
5053
services.styleNodeRange(node),
5154
]);

‎tools/update-fixtures.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const STYLE_CONTEXT_FIXTURE_ROOT = path.resolve(
2727
dirname,
2828
"../tests/fixtures/parser/style-context",
2929
);
30-
const STYLE_LOCATION_FIXTURE_ROOT = path.resolve(
30+
const STYLE_LOCATION_CONVERTER_FIXTURE_ROOT = path.resolve(
3131
dirname,
3232
"../tests/fixtures/parser/style-location-converter",
3333
);
@@ -165,7 +165,7 @@ for (const {
165165
outputFileName,
166166
config,
167167
meetRequirements,
168-
} of listupFixtures(STYLE_LOCATION_FIXTURE_ROOT)) {
168+
} of listupFixtures(STYLE_LOCATION_CONVERTER_FIXTURE_ROOT)) {
169169
if (!meetRequirements("parse")) {
170170
continue;
171171
}
@@ -176,16 +176,19 @@ for (const {
176176
continue;
177177
}
178178
const locations: [
179+
string,
179180
Partial<SourceLocation>,
180181
[number | undefined, number | undefined],
181182
][] = [
182183
[
184+
"root",
183185
services.styleNodeLoc(styleContext.sourceAst),
184186
services.styleNodeRange(styleContext.sourceAst),
185187
],
186188
];
187189
styleContext.sourceAst.walk((node) => {
188190
locations.push([
191+
node.type,
189192
services.styleNodeLoc(node),
190193
services.styleNodeRange(node),
191194
]);

0 commit comments

Comments
 (0)
Please sign in to comment.