Skip to content

Commit

Permalink
feat: add commonmark test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei686 authored and humyfred committed Feb 28, 2022
1 parent c76f93e commit 44287e3
Show file tree
Hide file tree
Showing 7 changed files with 5,248 additions and 21 deletions.
25 changes: 25 additions & 0 deletions test/core/Engine.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fs from 'fs'
import util from 'util';
import path from 'path';
import Cherry from '../../src/index';
import suites from '../suites/commonmark.spec.json';

const TEST_PATH = '../suites/engine.md';
const readFile = (fileName) => util.promisify(fs.readFile)(fileName, 'utf8');
const cherry = new Cherry({});

describe('engine', () => {
test('engine.md', () => {
return readFile(path.join(__dirname, TEST_PATH)).then((data) => {
// need to ignore error while accessing engine(private)
// @ts-ignore
expect(cherry.engine.makeHtml(data)).toMatchSnapshot();
});
});
test('commonmark', () => {
suites.forEach((item) => {
// @ts-ignore
expect(cherry.engine.makeHtml(item.markdown)).toBe(item.html);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`engine makeHtml 1`] = `
exports[`engine engine.md 1`] = `
"<h1 data-lines=\\"1\\" data-sign=\\"dac9d3dd9418fc39546123bf20e27749\\" id=\\"%E4%BE%8B%E5%AD%90\\"><a href=\\"#%E4%BE%8B%E5%AD%90\\" class=\\"anchor\\"></a>例子</h1>
<blockquote data-lines=\\"1\\" data-sign=\\"adadda3ce713b81a881a012ce64bf330_1\\"><a target=\\"_blank\\" rel=\\"nofollow\\" href=\\"https://github.com/Tencent/cherry-markdown\\">Github 地址</a></blockquote>
Expand Down
18 changes: 0 additions & 18 deletions test/core/hooks/Engine.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/core/hooks/List.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import List from '../../../src/core/hooks/List';
import * as md5 from 'md5';
import md5 from 'md5';

const cases = []
cases[0] = `
Expand Down
Loading

0 comments on commit 44287e3

Please sign in to comment.