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

feat(nodecli): ユニットテストのセクション、目次とサンプルコード #210

Merged
merged 5 commits into from
Apr 2, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion source/use-case/nodecli/refactor-and-unittest/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const filePath = program.args[0];

fs.readFile(filePath, "utf8", (err, file) => {
if (err) {
console.error(err.toString());
console.error(err);
process.exit(err.code);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>これはサンプルです。
<a href="https://asciidwango.github.io/js-primer/">https://asciidwango.github.io/js-primer/</a></p>
<p>これはHTMLです</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
これはサンプルです。
https://asciidwango.github.io/js-primer/

<p>これはHTMLです</p>
21 changes: 5 additions & 16 deletions source/use-case/nodecli/refactor-and-unittest/src/test/md2html.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
const assert = require("assert");
const fs = require("fs");
const md2html = require("../md2html");

const markdown = `
これはサンプルです。
https://asciidwango.github.io/js-primer/
it("default options", () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itを日本語にするか問題

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itはもっと説明的な内容でもいい気がする。
日本語でも良さそうではあるけど

const sample = fs.readFileSync("test/fixtures/sample.md", "utf8");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

微妙に requireと相対パス解決が違う __dirnameとpath.joinで解決するか

const expected = fs.readFileSync("test/fixtures/expected.html", "utf8");

<p>これはHTMLです</p>
`.trim();

describe("md2html", () => {
it("default options", () => {
const expected = `
<p>これはサンプルです。
<a href="https://asciidwango.github.io/js-primer/">https://asciidwango.github.io/js-primer/</a></p>
<p>これはHTMLです</p>
`.trim();

assert(md2html(markdown) === expected);
});
assert(md2html(sample) === expected);
});
2 changes: 1 addition & 1 deletion test/front-matter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("front-matter", function() {
`!${sourceDir}/README.md`,
`!${sourceDir}/OUTLINE.md`,
// サンプルコードの一部
`!${sourceDir}/use-case/nodecli/**/src/sample*.md`,
`!${sourceDir}/use-case/nodecli/**/src/**/sample*.md`,
]);
context("author", function() {
files.forEach(filePath => {
Expand Down