Skip to content
This repository has been archived by the owner on Nov 3, 2019. It is now read-only.

Commit

Permalink
test(mos-test): cover with tests the test reports
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Mar 29, 2016
1 parent 1f1c8b8 commit 39d1044
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
48 changes: 48 additions & 0 deletions lib/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,52 @@ describe('cli', () => {
return execa(cli, ['-v'])
.then(result => expect(result.stdout).to.eq(pkg.version))
})

describe('test', () => {
it('should pass markdown that is up to date', () => {
return execa(cli, ['test', 'test-cli/up-to-date.md', '--tap'], {
cwd: __dirname,
})
.then(result => expect(result.stdout).to.eq([
'TAP version 13',
'# markdown',
'ok 1 test-cli/up-to-date.md',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok',
'',
].join('\n')))
})

it('should fail markdown that is not up to date', () => {
return execa(cli, ['test', 'test-cli/not-up-to-date.md', '--tap'], {
cwd: __dirname,
})
.catch(result => {
expect(result.stdout).to.have.string([
'TAP version 13',
'# markdown',
'not ok 1 test-cli/not-up-to-date.md',
' ---',
' operator: equal',
' expected: |-',
" '<!--@\\'# \\' + package.name-->\\n# Bad title\\n<!--/@-->\\n\\nContent\\n'",
' actual: |-',
" '<!--@\\'# \\' + package.name-->\\n# slipsum-lite\\n<!--/@-->\\n\\nContent\\n'",
].join('\n'))

expect(result.stdout).to.have.string([
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1\n\n',
].join('\n'))
})
})
})
})
5 changes: 5 additions & 0 deletions lib/test-cli/not-up-to-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--@'# ' + package.name-->
# Bad title
<!--/@-->

Content
8 changes: 8 additions & 0 deletions lib/test-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "slipsum-lite",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/zkochan/mos"
}
}
5 changes: 5 additions & 0 deletions lib/test-cli/up-to-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Slipsum lite

You see? It's curious. Ted did figure it out - time travel. And when we get back, we gonna tell everyone. How it's possible, how it's done, what the dangers are. But then why fifty years in the future when the spacecraft encounters a black hole does the computer call it an 'unknown entry event'? Why don't they know? If they don't know, that means we never told anyone. And if we never told anyone it means we never made it back. Hence we die down here. Just as a matter of deductive logic.

Generated by (Samuel L. Ipsum)[http://slipsum.com/lite/]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"main": "index.js",
"scripts": {
"commit": "git-cz",
"md:test": "node ./lib/cli test",
"md:test": "node ./lib/cli test -x=\"lib/test-cli/**\"",
"lint": "eslint lib/** plugins/** index.js",
"test:code": "mocha",
"test": "npm run test:code && npm run lint && npm run md:test",
"coverage": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha -- -R spec",
"precoveralls": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && npm i coveralls@2",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"postcoveralls": "rm -rf ./coverage",
"md:update": "node ./lib/cli",
"md:update": "node ./lib/cli -x=\"lib/test-cli/**\"",
"prepublish": "npm test",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
Expand Down

0 comments on commit 39d1044

Please sign in to comment.