mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-22 05:55:13 +00:00
Add code block tests
This commit is contained in:
parent
5e7f17427b
commit
3a5732ce7d
1 changed files with 18 additions and 0 deletions
|
@ -173,16 +173,19 @@ describe('FullParser', () => {
|
|||
const output = [CODE_BLOCK('abc', null)];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
it('コードブロックには複数行のコードを入力できる', () => {
|
||||
const input = '```\na\nb\nc\n```';
|
||||
const output = [CODE_BLOCK('a\nb\nc', null)];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
it('コードブロックは言語を指定できる', () => {
|
||||
const input = '```js\nconst a = 1;\n```';
|
||||
const output = [CODE_BLOCK('const a = 1;', 'js')];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
it('ブロックの前後にあるテキストが正しく解釈される', () => {
|
||||
const input = 'abc\n```\nconst abc = 1;\n```\n123';
|
||||
const output = [
|
||||
|
@ -192,6 +195,21 @@ describe('FullParser', () => {
|
|||
];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
it('ignore internal marker', () => {
|
||||
const input = '```\naaa```bbb\n```';
|
||||
const output = [CODE_BLOCK('aaa```bbb', null)];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
|
||||
it('trim after line break', () => {
|
||||
const input = '```\nfoo\n```\nbar';
|
||||
const output = [
|
||||
CODE_BLOCK('foo', null),
|
||||
TEXT('bar'),
|
||||
];
|
||||
assert.deepStrictEqual(mfm.parse(input), output);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mathBlock', () => {
|
||||
|
|
Loading…
Reference in a new issue