Skip to content

Commit e78bd43

Browse files
committed
add test for invalid grid and interpolation syntax
1 parent 3f0195f commit e78bd43

File tree

3 files changed

+138
-1
lines changed

3 files changed

+138
-1
lines changed

src/__snapshots__/spec.test.ts.snap renamed to src/__snapshots__/extensions.spec.ts.snap

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,69 @@ exports[`Markdown extensions for grid add support for parsing custom grid syntax
924924
}
925925
`;
926926

927+
exports[`Markdown extensions for grid ignores incorrect grid like content 1`] = `
928+
{
929+
"children": [
930+
{
931+
"children": [
932+
{
933+
"position": {
934+
"end": {
935+
"column": 6,
936+
"line": 6,
937+
"offset": 42,
938+
},
939+
"start": {
940+
"column": 1,
941+
"line": 1,
942+
"offset": 0,
943+
},
944+
},
945+
"type": "text",
946+
"value": "% col
947+
orful
948+
%clo
949+
wn drinking
950+
%co
951+
fee",
952+
},
953+
],
954+
"position": {
955+
"end": {
956+
"column": 6,
957+
"line": 6,
958+
"offset": 42,
959+
},
960+
"start": {
961+
"column": 1,
962+
"line": 1,
963+
"offset": 0,
964+
},
965+
},
966+
"properties": {},
967+
"tagName": "p",
968+
"type": "element",
969+
},
970+
],
971+
"data": {
972+
"quirksMode": false,
973+
},
974+
"position": {
975+
"end": {
976+
"column": 1,
977+
"line": 1,
978+
"offset": 0,
979+
},
980+
"start": {
981+
"column": 1,
982+
"line": 1,
983+
"offset": 0,
984+
},
985+
},
986+
"type": "root",
987+
}
988+
`;
989+
927990
exports[`Markdown extensions for grid is able to parse deeply nested grid 1`] = `
928991
{
929992
"children": [
@@ -2285,6 +2348,64 @@ exports[`Markdown extensions for interpolation add support for interpolation syn
22852348
}
22862349
`;
22872350

2351+
exports[`Markdown extensions for interpolation ignores unmatched brackets 1`] = `
2352+
{
2353+
"children": [
2354+
{
2355+
"children": [
2356+
{
2357+
"position": {
2358+
"end": {
2359+
"column": 33,
2360+
"line": 1,
2361+
"offset": 32,
2362+
},
2363+
"start": {
2364+
"column": 1,
2365+
"line": 1,
2366+
"offset": 0,
2367+
},
2368+
},
2369+
"type": "text",
2370+
"value": "{{f} {f} {{f !{{f} !{f} !{{f",
2371+
},
2372+
],
2373+
"position": {
2374+
"end": {
2375+
"column": 33,
2376+
"line": 1,
2377+
"offset": 32,
2378+
},
2379+
"start": {
2380+
"column": 1,
2381+
"line": 1,
2382+
"offset": 0,
2383+
},
2384+
},
2385+
"properties": {},
2386+
"tagName": "p",
2387+
"type": "element",
2388+
},
2389+
],
2390+
"data": {
2391+
"quirksMode": false,
2392+
},
2393+
"position": {
2394+
"end": {
2395+
"column": 1,
2396+
"line": 1,
2397+
"offset": 0,
2398+
},
2399+
"start": {
2400+
"column": 1,
2401+
"line": 1,
2402+
"offset": 0,
2403+
},
2404+
},
2405+
"type": "root",
2406+
}
2407+
`;
2408+
22882409
exports[`Markdown extensions for interpolation works inside explicit markdown table 1`] = `
22892410
{
22902411
"children": [

src/spec.test.ts renamed to src/extensions.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ After grid
9999
!{{stringField}}`)
100100
).toMatchSnapshot();
101101
});
102+
103+
it("ignores incorrect grid like content", () => {
104+
expect(
105+
parse(`% col
106+
orful
107+
%clo
108+
wn drinking
109+
%co
110+
fee
111+
`)
112+
).toMatchSnapshot();
113+
});
102114
});
103115

104116
describe("for interpolation", () => {
@@ -141,6 +153,10 @@ and appear !{{inline|with=argument}} like this
141153
`)
142154
).toMatchSnapshot();
143155
});
156+
157+
it("ignores unmatched brackets", () => {
158+
expect(parse("{{f} {f} {{f !{{f} !{f} !{{f")).toMatchSnapshot();
159+
});
144160
});
145161

146162
describe("backward compatibility", () => {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"strictNullChecks": true
1515
},
1616
"include": ["src/**/*"],
17-
"exclude": ["src/**/*.test.ts"]
17+
"exclude": ["src/**/*.spec.ts"]
1818
}

0 commit comments

Comments
 (0)