Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
https://markdown-it.github.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.5 KiB
86 lines
2.5 KiB
1 year ago
|
import { assert } from 'chai';
|
||
|
import utils from '../lib/common/utils.js';
|
||
10 years ago
|
|
||
|
|
||
|
describe('Utils', function () {
|
||
|
|
||
|
it('fromCodePoint', function () {
|
||
1 year ago
|
var fromCodePoint = utils.fromCodePoint;
|
||
10 years ago
|
|
||
|
assert.strictEqual(fromCodePoint(0x20), ' ');
|
||
|
assert.strictEqual(fromCodePoint(0x1F601), '😁');
|
||
|
});
|
||
|
|
||
|
it('isValidEntityCode', function () {
|
||
1 year ago
|
var isValidEntityCode = utils.isValidEntityCode;
|
||
10 years ago
|
|
||
|
assert.strictEqual(isValidEntityCode(0x20), true);
|
||
|
assert.strictEqual(isValidEntityCode(0xD800), false);
|
||
|
assert.strictEqual(isValidEntityCode(0xFDD0), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x1FFFF), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x1FFFE), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x00), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x0B), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x0E), false);
|
||
|
assert.strictEqual(isValidEntityCode(0x7F), false);
|
||
|
});
|
||
|
|
||
10 years ago
|
/*it('replaceEntities', function () {
|
||
1 year ago
|
var replaceEntities = utils.replaceEntities;
|
||
10 years ago
|
|
||
|
assert.strictEqual(replaceEntities('&'), '&');
|
||
|
assert.strictEqual(replaceEntities(' '), ' ');
|
||
|
assert.strictEqual(replaceEntities(' '), ' ');
|
||
|
assert.strictEqual(replaceEntities('&&'), '&&');
|
||
|
|
||
|
assert.strictEqual(replaceEntities('&am;'), '&am;');
|
||
|
assert.strictEqual(replaceEntities('�'), '�');
|
||
10 years ago
|
});*/
|
||
10 years ago
|
|
||
|
it('assign', function () {
|
||
1 year ago
|
var assign = utils.assign;
|
||
10 years ago
|
|
||
|
assert.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 });
|
||
|
assert.throws(function () {
|
||
|
assign({}, 123);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('escapeRE', function () {
|
||
1 year ago
|
var escapeRE = utils.escapeRE;
|
||
10 years ago
|
|
||
|
assert.strictEqual(escapeRE(' .?*+^$[]\\(){}|-'), ' \\.\\?\\*\\+\\^\\$\\[\\]\\\\\\(\\)\\{\\}\\|\\-');
|
||
|
});
|
||
|
|
||
|
it('isWhiteSpace', function () {
|
||
1 year ago
|
var isWhiteSpace = utils.isWhiteSpace;
|
||
10 years ago
|
|
||
|
assert.strictEqual(isWhiteSpace(0x2000), true);
|
||
|
assert.strictEqual(isWhiteSpace(0x09), true);
|
||
|
|
||
|
assert.strictEqual(isWhiteSpace(0x30), false);
|
||
|
});
|
||
|
|
||
|
it('isMdAsciiPunct', function () {
|
||
1 year ago
|
var isMdAsciiPunct = utils.isMdAsciiPunct;
|
||
10 years ago
|
|
||
|
assert.strictEqual(isMdAsciiPunct(0x30), false);
|
||
|
|
||
|
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.split('').forEach(function (ch) {
|
||
|
assert.strictEqual(isMdAsciiPunct(ch.charCodeAt(0)), true);
|
||
|
});
|
||
10 years ago
|
});
|
||
|
|
||
|
it('unescapeMd', function () {
|
||
1 year ago
|
var unescapeMd = utils.unescapeMd;
|
||
10 years ago
|
|
||
10 years ago
|
assert.strictEqual(unescapeMd('\\foo'), '\\foo');
|
||
|
assert.strictEqual(unescapeMd('foo'), 'foo');
|
||
10 years ago
|
|
||
10 years ago
|
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.split('').forEach(function (ch) {
|
||
|
assert.strictEqual(unescapeMd('\\' + ch), ch);
|
||
|
});
|
||
10 years ago
|
});
|
||
|
|
||
|
});
|