Skip to content

Commit 06314c0

Browse files
author
whyboris
committed
simple unit test for preview and postToDiffy
1 parent 8358796 commit 06314c0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/cli-tests.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var assert = require('assert');
33
var sinon = require('sinon')
44

55
var Cli = require('../src/cli.js').Diff2HtmlInterface;
6+
var http = require('../src/http-utils.js').HttpUtils;
67
var Utils = require('../src/utils.js').Utils;
78

89
describe('Cli', function() {
@@ -24,9 +25,26 @@ describe('Cli', function() {
2425

2526
it('should _runGitDiff by default', function() {
2627
let spy = sinon.stub(Cli, '_runGitDiff');
27-
Cli.getInput('abc', ['lol'], 'callback');
28+
Cli.getInput('abc', ['lol', 'foo'], 'callback');
2829
assert(spy.calledOnce);
29-
assert(spy.calledWith(['lol'], 'callback'));
30+
assert(spy.calledWith(['lol', 'foo'], 'callback'));
31+
});
32+
});
33+
34+
describe('preview', function() {
35+
it('should call `utils.writeFile`', function() {
36+
let spy = sinon.stub(Utils, 'writeFile');
37+
Cli.preview('a', 'b');
38+
assert(spy.calledOnce);
39+
});
40+
});
41+
42+
describe('postToDiffy', function() {
43+
it('should call `http.post`', function() {
44+
let spy = sinon.stub(http, 'post');
45+
Cli.postToDiffy('a', 'b', 'callback');
46+
assert(spy.calledOnce);
47+
assert(spy.calledWith('http://diffy.org/api/new', { udiff: 'a' }));
3048
});
3149
});
3250
});

0 commit comments

Comments
 (0)