-
Couldn't load subscription status.
- Fork 53
Some unit tests for the cli #45
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
Changes from 14 commits
8358796
06314c0
0a9a054
ec4b429
cdabb61
4f80e16
7a9191f
eda5a99
89ee810
c23099c
bfbee97
c3b708d
9352385
0f4a37c
79b581a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ jobs: | |
| - ./node_modules | ||
| - run: npm run coverage | ||
| - run: npm run check-coverage | ||
| - run: npm run report | ||
|
|
||
| build-latest: &latest-build | ||
| docker: | ||
|
|
@@ -31,18 +32,9 @@ jobs: | |
| - ./node_modules | ||
| - run: yarn run test | ||
| - run: yarn run lint | ||
| - run: yarn run coverage-lcov | ||
| - run: yarn run codacy | ||
|
|
||
| build-node_4: | ||
| <<: *common-build | ||
| docker: | ||
| - image: node:4 | ||
|
|
||
| build-node_5: | ||
| <<: *common-build | ||
| docker: | ||
| - image: node:5 | ||
|
|
||
| build-node_6: | ||
| <<: *common-build | ||
| docker: | ||
|
|
@@ -68,14 +60,18 @@ jobs: | |
| docker: | ||
| - image: node:10 | ||
|
|
||
| build-node_11: | ||
| <<: *latest-build | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. Can you change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry have never dealt with this file / config before -- should have been less cavalier when copy-pasting the last command (node 10 -> 11) 😓 |
||
| docker: | ||
| - image: node:11 | ||
|
|
||
| workflows: | ||
| version: 2 | ||
| build: | ||
| jobs: | ||
| - build-node_4 | ||
| - build-node_5 | ||
| - build-node_6 | ||
| - build-node_7 | ||
| - build-node_8 | ||
| - build-node_9 | ||
| - build-node_10 | ||
| - build-node_11 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,9 @@ node_modules/ | |
| npm-debug.log | ||
| yarn-error.log | ||
|
|
||
| # Istanbul | ||
| # NYC | ||
| coverage/ | ||
| .nyc_output/ | ||
|
|
||
| # Bower | ||
| bower_components/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| var assert = require('assert'); | ||
|
|
||
| var sinon = require('sinon'); | ||
|
|
||
| var Cli = require('../src/cli.js').Diff2HtmlInterface; | ||
| var http = require('../src/http-utils.js').HttpUtils; | ||
| var Utils = require('../src/utils.js').Utils; | ||
|
|
||
| describe('Cli', function() { | ||
| describe('getInput', function() { | ||
| it('should readFile when inputType is `file`', function() { | ||
| var spy = sinon.stub(Utils, 'readFile'); | ||
| Cli.getInput('file', ['lol', 'foo'], 'ignore', 'callback'); | ||
| assert(spy.calledOnce); | ||
| assert(spy.calledWith('lol', 'callback')); | ||
| spy.restore(); | ||
| }); | ||
|
|
||
| it('should readStdin when inputType is `stdin`', function() { | ||
| var spy = sinon.stub(Utils, 'readStdin'); | ||
| Cli.getInput('stdin', ['lol'], 'ignore', 'callback'); | ||
| assert(spy.calledOnce); | ||
| assert(spy.calledWith('callback')); | ||
| spy.restore(); | ||
| }); | ||
|
|
||
| it('should _runGitDiff by default', function() { | ||
| var spy = sinon.stub(Cli, '_runGitDiff'); | ||
| Cli.getInput('abc', ['lol', 'foo'], 'ignore', 'callback'); | ||
| assert(spy.calledOnce); | ||
| assert(spy.calledWith(['lol', 'foo'], 'ignore', 'callback')); | ||
| }); | ||
| }); | ||
|
|
||
| describe('preview', function() { | ||
| it('should call `utils.writeFile`', function() { | ||
| var spy = sinon.stub(Utils, 'writeFile'); | ||
| Cli.preview('a', 'b'); | ||
| assert(spy.calledOnce); | ||
| spy.restore(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('postToDiffy', function() { | ||
| it('should call `http.post`', function() { | ||
| var spy = sinon.stub(http, 'post'); | ||
| Cli.postToDiffy('a', 'b', 'callback'); | ||
| assert(spy.calledOnce); | ||
| assert(spy.calledWith('http://diffy.org/api/new', { udiff: 'a' })); | ||
| }); | ||
| }); | ||
| }); |