Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: es6-fy #104

Merged
merged 1 commit into from
Jul 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line
var util = require('hexo-util');
const should = require('chai').should(); // eslint-disable-line
const util = require('hexo-util');

describe('Marked renderer', function() {
var ctx = {
describe('Marked renderer', () => {
const ctx = {
config: {
marked: {}
}
};

var r = require('../lib/renderer').bind(ctx);
const r = require('../lib/renderer').bind(ctx);

it('default', function() {
var code = 'console.log("Hello world");';
it('default', () => {
const code = 'console.log("Hello world");';

var body = [
const body = [
'# Hello world',
'',
'```',
Expand All @@ -27,7 +27,7 @@ describe('Marked renderer', function() {
'hello'
].join('\n');

var result = r({text: body});
const result = r({text: body});

result.should.eql([
'<h1 id="Hello-world"><a href="#Hello-world" class="headerlink" title="Hello world"></a>Hello world</h1>',
Expand All @@ -37,86 +37,86 @@ describe('Marked renderer', function() {
].join('') + '\n');
});

it('should render headings with links', function() {
var body = [
it('should render headings with links', () => {
const body = [
'## [hexo-server]',
'',
'[hexo-server]: https://github.com/hexojs/hexo-server'
].join('\n');

var result = r({text: body});
const result = r({text: body});

result.should.eql([
'<h2 id="hexo-server"><a href="#hexo-server" class="headerlink" title="hexo-server"></a>',
'<a href="https://github.com/hexojs/hexo-server">hexo-server</a></h2>'
].join(''));
});

it('should handle chinese headers properly', function() {
var body = '# 中文';
var result = r({text: body});
it('should handle chinese headers properly', () => {
const body = '# 中文';
const result = r({text: body});

result.should.eql('<h1 id="中文"><a href="#中文" class="headerlink" title="中文"></a>中文</h1>');
});

// Description List tests

it('should render description lists with a single space after the colon', function() {
var result = r({text: 'Description Term<br>: This is the Description'});
it('should render description lists with a single space after the colon', () => {
const result = r({text: 'Description Term<br>: This is the Description'});
result.should.eql('<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>');
});

it('should render description lists with multiple spaces after the colon', function() {
var result = r({text: 'Description Term<br>: This is the Description'});
it('should render description lists with multiple spaces after the colon', () => {
const result = r({text: 'Description Term<br>: This is the Description'});
result.should.eql('<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>');
});

it('should render description lists with a tab after the colon', function() {
var result = r({text: 'Description Term<br>: This is the Description'});
it('should render description lists with a tab after the colon', () => {
const result = r({text: 'Description Term<br>: This is the Description'});
result.should.eql('<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>');
});

it('should render description lists with a carriage return after the colon', function() {
var result = r({text: 'Description Term<br>:\nThis is the Description'});
it('should render description lists with a carriage return after the colon', () => {
const result = r({text: 'Description Term<br>:\nThis is the Description'});
result.should.eql('<dl><dt>Description Term</dt><dd>This is the Description</dd></dl>');
});

it('should not render regular paragraphs as description lists', function() {
var result = r({text: 'Description Term<br>:This is the Description'});
it('should not render regular paragraphs as description lists', () => {
const result = r({text: 'Description Term<br>:This is the Description'});
result.should.eql('<p>Description Term<br>:This is the Description</p>\n');
});

describe('autolink option tests', function() {
var ctx = {
describe('autolink option tests', () => {
const ctx = {
config: {
marked: {
autolink: true
}
}
};

var renderer = require('../lib/renderer');
const renderer = require('../lib/renderer');

var body = [
const body = [
'Great website http://hexo.io',
'',
'[Hexo](http://hexo.io)'
].join('\n');

it('autolink enabled', function() {
var r = renderer.bind(ctx);
var result = r({text: body});
it('autolink enabled', () => {
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<p>Great website <a href="http://hexo.io">http://hexo.io</a></p>\n',
'<p><a href="http://hexo.io">Hexo</a></p>\n'
].join(''));
});

it('autolink disabled', function() {
it('autolink disabled', () => {
ctx.config.marked.autolink = false;
var r = renderer.bind(ctx);
var result = r({text: body});
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<p>Great website http://hexo.io</p>\n',
Expand All @@ -125,26 +125,26 @@ describe('Marked renderer', function() {
});
});

describe('modifyAnchors option tests', function() {
var body = [
describe('modifyAnchors option tests', () => {
const body = [
'- [Example](#example)',
'',
'# Example'
].join('\n');

var renderer = require('../lib/renderer');
const renderer = require('../lib/renderer');

var ctx = {
const ctx = {
config: {
marked: {
modifyAnchors: ''
}
}
};

it('should not modify anchors with default options', function() {
var r = renderer.bind(ctx);
var result = r({text: body});
it('should not modify anchors with default options', () => {
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<ul>',
Expand All @@ -154,10 +154,10 @@ describe('Marked renderer', function() {
].join('\n'));
});

it('should set anchors to upperCase in case of modifyAnchors option is 2', function() {
it('should set anchors to upperCase in case of modifyAnchors option is 2', () => {
ctx.config.marked.modifyAnchors = 2;
var r = renderer.bind(ctx);
var result = r({text: body});
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<ul>',
Expand All @@ -167,10 +167,10 @@ describe('Marked renderer', function() {
].join('\n'));
});

it('should set anchors to lowerCase in case of modifyAnchors option is 1', function() {
it('should set anchors to lowerCase in case of modifyAnchors option is 1', () => {
ctx.config.marked.modifyAnchors = 1;
var r = renderer.bind(ctx);
var result = r({text: body});
const r = renderer.bind(ctx);
const result = r({text: body});

result.should.eql([
'<ul>',
Expand Down