Skip to content

Commit 70d5149

Browse files
shufoczosel
authored andcommitted
test: 💍 add test for multiline class constant
1 parent de0a239 commit 70d5149

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/snapshot/__snapshots__/classconstant.test.js.snap

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,59 @@ Program {
4949
}
5050
`;
5151

52+
exports[`classconstant multiline declaration with comment 1`] = `
53+
Program {
54+
"children": [
55+
Class {
56+
"attrGroups": [],
57+
"body": [
58+
ClassConstant {
59+
"attrGroups": [],
60+
"constants": [
61+
Constant {
62+
"kind": "constant",
63+
"name": Identifier {
64+
"kind": "identifier",
65+
"name": "CONSTANT",
66+
},
67+
"value": String {
68+
"isDoubleQuote": true,
69+
"kind": "string",
70+
"raw": ""Hello world!"",
71+
"unicode": false,
72+
"value": "Hello world!",
73+
},
74+
},
75+
],
76+
"final": false,
77+
"kind": "classconstant",
78+
"nullable": false,
79+
"type": TypeReference {
80+
"kind": "typereference",
81+
"name": "string",
82+
"raw": "string",
83+
},
84+
"visibility": "public",
85+
},
86+
],
87+
"extends": null,
88+
"implements": null,
89+
"isAbstract": false,
90+
"isAnonymous": false,
91+
"isFinal": false,
92+
"isReadonly": false,
93+
"kind": "class",
94+
"name": Identifier {
95+
"kind": "identifier",
96+
"name": "Foo",
97+
},
98+
},
99+
],
100+
"errors": [],
101+
"kind": "program",
102+
}
103+
`;
104+
52105
exports[`classconstant multiple 1`] = `
53106
Program {
54107
"children": [

test/snapshot/classconstant.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,24 @@ describe("classconstant", () => {
7575
),
7676
).toThrowErrorMatchingSnapshot();
7777
});
78+
it("multiline declaration with comment", () => {
79+
expect(
80+
parser.parseEval(
81+
`class Foo {
82+
public
83+
// comment 1
84+
const
85+
// comment 2
86+
string
87+
// comment 3
88+
CONSTANT
89+
// comment 4
90+
=
91+
// comment 5
92+
"Hello world!";
93+
}`,
94+
{ parser: { version: 803 } },
95+
),
96+
).toMatchSnapshot();
97+
});
7898
});

0 commit comments

Comments
 (0)