Skip to content

Commit

Permalink
use arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Mar 12, 2019
1 parent 24d6f19 commit fb9a71c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions test/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const marked = require('../../');
const HtmlDiffer = require('@markedjs/html-differ').HtmlDiffer;
const htmlDiffer = new HtmlDiffer({ignoreSelfClosingSlash: true});

beforeEach(function () {
beforeEach(() => {
marked.setOptions(marked.getDefaults());

jasmine.addMatchers({
toRender: function () {
toRender: () => {
return {
compare: function (spec, expected) {
compare: (spec, expected) => {
const result = {};
const actual = marked(spec.markdown, spec.options);
result.pass = htmlDiffer.isEqual(expected, actual);
Expand Down
2 changes: 1 addition & 1 deletion test/specs/original/specs-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var specTests = require('../../');

it('should run spec tests', function () {
it('should run spec tests', () => {
// hide output
spyOn(console, 'log');
if (!specTests(['', '', '--stop'])) {
Expand Down
8 changes: 4 additions & 4 deletions test/specs/run-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ function runSpecs(title, file, options) {
return obj;
}, {});

describe(title, function() {
describe(title, () => {
Object.keys(specs).forEach(section => {
describe(section, function() {
specs[section].forEach(function(spec) {
describe(section, () => {
specs[section].forEach((spec) => {
if (options) {
spec.options = Object.assign({}, options, (spec.options || {}));
}
(spec.only ? fit : it)('should ' + (spec.shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() {
(spec.only ? fit : it)('should ' + (spec.shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, () => {
if (spec.shouldFail) {
expect(spec).not.toRender(spec.html);
} else {
Expand Down
26 changes: 13 additions & 13 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
var marked = require('../../lib/marked.js');

describe('Test heading ID functionality', function() {
it('should add id attribute by default', function() {
describe('Test heading ID functionality', () => {
it('should add id attribute by default', () => {
var renderer = new marked.Renderer();
var slugger = new marked.Slugger();
var header = renderer.heading('test', 1, 'test', slugger);
expect(header).toBe('<h1 id="test">test</h1>\n');
});

it('should NOT add id attribute when options set false', function() {
it('should NOT add id attribute when options set false', () => {
var renderer = new marked.Renderer({ headerIds: false });
var header = renderer.heading('test', 1, 'test');
expect(header).toBe('<h1>test</h1>\n');
});
});

describe('Test slugger functionality', function() {
it('should use lowercase slug', function() {
describe('Test slugger functionality', () => {
it('should use lowercase slug', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('Test')).toBe('test');
});

it('should be unique to avoid collisions 1280', function() {
it('should be unique to avoid collisions 1280', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('test')).toBe('test');
expect(slugger.slug('test')).toBe('test-1');
expect(slugger.slug('test')).toBe('test-2');
});

it('should be unique when slug ends with number', function() {
it('should be unique when slug ends with number', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('test 1')).toBe('test-1');
expect(slugger.slug('test')).toBe('test');
expect(slugger.slug('test')).toBe('test-2');
});

it('should be unique when slug ends with hyphen number', function() {
it('should be unique when slug ends with hyphen number', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('foo')).toBe('foo');
expect(slugger.slug('foo')).toBe('foo-1');
Expand All @@ -44,24 +44,24 @@ describe('Test slugger functionality', function() {
expect(slugger.slug('foo')).toBe('foo-2');
});

it('should allow non-latin chars', function() {
it('should allow non-latin chars', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('привет')).toBe('привет');
});

it('should remove ampersands 857', function() {
it('should remove ampersands 857', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('This & That Section')).toBe('this--that-section');
});

it('should remove periods', function() {
it('should remove periods', () => {
var slugger = new marked.Slugger();
expect(slugger.slug('file.txt')).toBe('filetxt');
});
});

describe('Test paragraph token type', function () {
it('should use the "paragraph" type on top level', function () {
describe('Test paragraph token type', () => {
it('should use the "paragraph" type on top level', () => {
const md = 'A Paragraph.\n\n> A blockquote\n\n- list item\n';

const tokens = marked.lexer(md);
Expand Down

0 comments on commit fb9a71c

Please sign in to comment.