Skip to content

Commit b5fd61b

Browse files
sasahara-studysasahara
andauthored
fix(nodecli): 末尾の改行コードを削除 (#1234)
* fix_cli_test_code 末尾の改行コードを削除 * fix(nodecli) 末尾の改行コードを削除 trimEnd()に変更、コメントとexpectedに対しての末尾空白行の削除を追加 * fix(nodecli) 対象にユニットテストを追加 Co-authored-by: sasahara <[email protected]>
1 parent 0e85086 commit b5fd61b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test:example": "mocha test/",
3333
"test:basic": "mocha \"./source/basic/**/*-test.js\"",
3434
"test:nodecli": "cd ./source/use-case/nodecli && npm install && npm test",
35+
"test:nodecli-unittest": "cd ./source/use-case/nodecli/refactor-and-unittest/src/test && npm install && npm test",
3536
"test:ajaxapp": "mocha \"./source/use-case/ajaxapp/!(node_modules)**/*-test.js\"",
3637
"test:todoapp": "cd ./source/use-case/todoapp && npm install && npm test",
3738
"test": "npm-run-all -l --parallel test:* lint",

source/use-case/nodecli/refactor-and-unittest/src/test/md2html-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ it("converts Markdown to HTML (GFM=false)", () => {
77
// fs.readFileSyncは同期的にファイルを読み込むメソッド
88
const sample = fs.readFileSync(path.resolve(__dirname, "./fixtures/sample.md"), { encoding: "utf8" });
99
const expected = fs.readFileSync(path.resolve(__dirname, "./fixtures/expected.html"), { encoding: "utf8" });
10-
11-
assert.strictEqual(md2html(sample, { gfm: false }), expected);
10+
// 末尾の改行の有無の違いを無視するため、変換後のHTMLのスペースをtrimメソッドで削除してから比較しています
11+
assert.strictEqual(md2html(sample, { gfm: false }).trimEnd(), expected.trimEnd());
1212
});
1313

1414
it("converts Markdown to HTML (GFM=true)", () => {
1515
const sample = fs.readFileSync(path.resolve(__dirname, "./fixtures/sample.md"), { encoding: "utf8" });
1616
const expected = fs.readFileSync(path.resolve(__dirname, "./fixtures/expected-gfm.html"), { encoding: "utf8" });
17-
18-
assert.strictEqual(md2html(sample, { gfm: true }), expected);
17+
// 末尾の改行の有無の違いを無視するため、変換後のHTMLのスペースをtrimメソッドで削除してから比較しています
18+
assert.strictEqual(md2html(sample, { gfm: true }).trimEnd(), expected.trimEnd());
1919
});
2020

0 commit comments

Comments
 (0)