summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-markdown/test/summary.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-markdown/test/summary.js')
-rw-r--r--packages/gitbook-markdown/test/summary.js81
1 files changed, 41 insertions, 40 deletions
diff --git a/packages/gitbook-markdown/test/summary.js b/packages/gitbook-markdown/test/summary.js
index 31dbff9..9748500 100644
--- a/packages/gitbook-markdown/test/summary.js
+++ b/packages/gitbook-markdown/test/summary.js
@@ -1,8 +1,8 @@
-var fs = require('fs');
-var path = require('path');
-var assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+const expect = require('expect');
-var summary = require('../').summary;
+const summary = require('../src').summary;
function lex(fixtureFile) {
return summary(
@@ -13,61 +13,62 @@ function lex(fixtureFile) {
);
}
-describe('Summary parsing', function () {
- var LEXED;
+describe('Summary', () => {
+ let LEXED, PART;
- before(function() {
+ before(() => {
LEXED = lex('SUMMARY.md');
PART = LEXED.parts[0];
});
- it('should detect chapters', function() {
- assert.equal(PART.articles.length, 5);
+ it('should detect chapters', () => {
+ expect(PART.articles.length).toBe(5);
});
- it('should support articles', function() {
- assert.equal(PART.articles[0].articles.length, 2);
- assert.equal(PART.articles[1].articles.length, 0);
- assert.equal(PART.articles[2].articles.length, 0);
+ it('should support articles', () => {
+ expect(PART.articles[0].articles.length).toBe(2);
+ expect(PART.articles[1].articles.length).toBe(0);
+ expect(PART.articles[2].articles.length).toBe(0);
});
- it('should detect paths and titles', function() {
- assert(PART.articles[0].ref);
- assert(PART.articles[1].ref);
- assert(PART.articles[2].ref);
- assert(PART.articles[3].ref);
- assert.equal(PART.articles[4].ref, null);
+ it('should detect paths and titles', () => {
+ expect(PART.articles[0].ref).toExist();
+ expect(PART.articles[1].ref).toExist();
+ expect(PART.articles[2].ref).toExist();
+ expect(PART.articles[3].ref).toExist();
+ expect(PART.articles[4].ref).toNotExist();
- assert(PART.articles[0].title);
- assert(PART.articles[1].title);
- assert(PART.articles[2].title);
- assert(PART.articles[3].title);
- assert(PART.articles[4].title);
+ expect(PART.articles[0].title).toExist();
+ expect(PART.articles[1].title).toExist();
+ expect(PART.articles[2].title).toExist();
+ expect(PART.articles[3].title).toExist();
+ expect(PART.articles[4].title).toExist();
});
- it('should normalize paths from .md', function() {
- assert.equal(PART.articles[0].ref, 'chapter-1/README.md');
- assert.equal(PART.articles[1].ref, 'chapter-2/README.md');
- assert.equal(PART.articles[2].ref, 'chapter-3/README.md');
+ it('should normalize paths from .md', () => {
+ expect(PART.articles[0].ref).toBe('chapter-1/README.md');
+ expect(PART.articles[1].ref).toBe('chapter-2/README.md');
+ expect(PART.articles[2].ref).toBe('chapter-3/README.md');
});
- it('should part parts', function() {
- var l = lex('SUMMARY_PARTS.md');
- assert.equal(l.parts.length, 3);
+ it('should part parts', () => {
+ const l = lex('SUMMARY_PARTS.md');
+ expect(l.parts.length).toBe(3);
});
- it('should allow lists separated by whitespace', function() {
- var l = lex('SUMMARY_WHITESPACE.md');
- assert.equal(l.parts[0].articles.length, 5);
+ it('should allow lists separated by whitespace', () => {
+ const l = lex('SUMMARY_WHITESPACE.md');
+ expect(l.parts[0].articles.length).toBe(5);
});
- it('should allow ignore empty entries', function() {
- var l = lex('SUMMARY_EMPTY.md');
- assert.equal(l.parts[0].articles.length, 1);
+ it('should allow ignore empty entries', () => {
+ const l = lex('SUMMARY_EMPTY.md');
+ expect(l.parts[0].articles.length).toBe(1);
});
- it('should correctly convert it to text', function() {
- var text = summary.toText(LEXED);
- assertObjectsEqual(summary(text), LEXED);
+ it('should correctly convert it to text', () => {
+ const text = summary.toText(LEXED);
+ const parsed = summary(text);
+ expect(parsed).toEqual(LEXED);
});
});