Skip to content

Commit

Permalink
test: add testcase for escaped chars
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 2, 2024
1 parent 3cd5c5a commit ebca643
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 59 deletions.
47 changes: 47 additions & 0 deletions test/__snapshots__/attributes.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,53 @@ exports[`Attributes > id-suger 1`] = `
}
`;

exports[`Attributes > ignoreEscapeAttrInNormalAttribute 1`] = `
{
"children": [
{
"attributes": {
"code": "D:\\Software\\",
},
"children": [],
"data": {
"hName": "copy",
"hProperties": {
"code": "D:\\Software\\",
},
},
"fmAttributes": {},
"name": "copy",
"position": {
"end": {
"column": 29,
"line": 1,
"offset": 28,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "textComponent",
},
],
"position": {
"end": {
"column": 29,
"line": 1,
"offset": 28,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;

exports[`Attributes > image 1`] = `
{
"children": [
Expand Down
59 changes: 0 additions & 59 deletions test/__snapshots__/codeblock-props.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -500,65 +500,6 @@ key: value
}
`;

exports[`codeblock-props > shouldConvertYamlPropsWithoutOption 1`] = `
{
"children": [
{
"attributes": {},
"children": [],
"data": {
"hName": "with-frontmatter-yaml",
"hProperties": {
":array": "["item",{"itemKey":"value"}]",
"key": "value",
},
},
"fmAttributes": {
"array": [
"item",
{
"itemKey": "value",
},
],
"key": "value",
},
"name": "with-frontmatter-yaml",
"position": {
"end": {
"column": 3,
"line": 8,
"offset": 92,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"rawData": "array:
- item
- itemKey: value
key: value
---",
"type": "containerComponent",
},
],
"position": {
"end": {
"column": 3,
"line": 8,
"offset": 92,
},
"start": {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;

exports[`codeblock-props > yamlProps1 1`] = `
{
"children": [
Expand Down
9 changes: 9 additions & 0 deletions test/attributes.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe } from 'vitest'

Check failure on line 1 in test/attributes.test.ts

View workflow job for this annotation

GitHub Actions / ci

'/home/runner/work/remark-mdc/remark-mdc/node_modules/vitest/dist/index.js' imported multiple times
import { runMarkdownTests } from './utils'
import { expect } from 'vitest'

Check failure on line 3 in test/attributes.test.ts

View workflow job for this annotation

GitHub Actions / ci

`vitest` import should occur before import of `./utils`

Check failure on line 3 in test/attributes.test.ts

View workflow job for this annotation

GitHub Actions / ci

'/home/runner/work/remark-mdc/remark-mdc/node_modules/vitest/dist/index.js' imported multiple times

describe('Attributes', () => {
runMarkdownTests({
Expand Down Expand Up @@ -61,6 +62,14 @@ describe('Attributes', () => {
'emphasis': {
markdown: '_emphasis_{#id .class}',
},
ignoreEscapeAttrInNormalAttribute: {

Check failure on line 65 in test/attributes.test.ts

View workflow job for this annotation

GitHub Actions / ci

Inconsistently quoted property 'ignoreEscapeAttrInNormalAttribute' found
markdown: ':copy{code="D:\\\\Software\\\\"}',
expected: ':copy{code="D:\\Software\\"}',
extra: (_md, ast) => {
expect(ast.children[0].type).toBe('textComponent')
expect(ast.children[0].attributes.code).toBe('D:\\Software\\')
}

Check failure on line 71 in test/attributes.test.ts

View workflow job for this annotation

GitHub Actions / ci

Missing trailing comma
},
'nested-in-table': {
markdown: [
'| Col1 | Col2 |',
Expand Down

0 comments on commit ebca643

Please sign in to comment.