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

API refactors #21

Merged
merged 7 commits into from
Mar 21, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
fix compiler tests
  • Loading branch information
Gilad Gray committed Mar 21, 2017
commit 8acf9849d563369b35f77ab56d57c0294f3c5e07
26 changes: 13 additions & 13 deletions test/compilerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ describe("Compiler", () => {
const MARKDOWN = "# Title\nbody body body";
const OBJECT = { hello: "world", size: 1000 };

it("extracts contents and parses metadata", () => {
it("extracts contentsRaw and parses metadata", () => {
const data = API.renderBlock(METADATA + MARKDOWN);
assert.strictEqual(data.content, MARKDOWN);
assert.strictEqual(data.contentsRaw, MARKDOWN);
assert.deepEqual(data.metadata, OBJECT);
});

it("supports empty metadata block", () => {
const data = API.renderBlock("---\n---\n" + MARKDOWN);
assert.strictEqual(data.content, MARKDOWN);
assert.strictEqual(data.contentsRaw, MARKDOWN);
assert.deepEqual(data.metadata, {});
});

it("metadata block is optional", () => {
const data = API.renderBlock(MARKDOWN);
assert.strictEqual(data.content, MARKDOWN);
assert.strictEqual(data.contentsRaw, MARKDOWN);
assert.deepEqual(data.metadata, {});
});
});

describe("renderedContent", () => {
describe("rendered contents", () => {
const FILE = `
# Title
description
Expand All @@ -45,21 +45,21 @@ more description
`;

it("returns a single-element array for string without @tags", () => {
const { renderedContent } = API.renderBlock("simple string");
assert.deepEqual(renderedContent, ["<p>simple string</p>\n"]);
const { contents } = API.renderBlock("simple string");
assert.deepEqual(contents, ["<p>simple string</p>\n"]);
});

it("converts @tag to object in array", () => {
const { renderedContent } = API.renderBlock(FILE);
assert.equal(renderedContent.length, 3);
assert.deepEqual(renderedContent[1], { tag: "interface", value: "IButtonProps" });
const { contents } = API.renderBlock(FILE);
assert.equal(contents.length, 3);
assert.deepEqual(contents[1], { tag: "interface", value: "IButtonProps" });
});

it("reservedWords will ignore matching @tag", () => {
const { renderedContent } = API.renderBlock(FILE, ["interface"]);
assert.equal(renderedContent.length, 3);
const { contents } = API.renderBlock(FILE, ["interface"]);
assert.equal(contents.length, 3);
// reserved @tag is emitted as separate string cuz it's still split by regex
assert.deepEqual(renderedContent[1], "<p>@interface IButtonProps</p>\n");
assert.deepEqual(contents[1], "<p>@interface IButtonProps</p>\n");
});

});
Expand Down