Repository navigation
Expand file tree
/
Copy pathcli.info.js
More file actions
72 lines (64 loc) · 2.17 KB
/
Copy pathcli.info.js
File metadata and controls
72 lines (64 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"use strict";
var info = require("../../../lib/cli/cli-info");
var assert = require("chai").assert;
var sinon = require("sinon");
var fs = require("fs");
describe("CLI: Info Helpers:", function () {
describe("When displaying the version number", function () {
var consoleLogStub;
before(function () {
consoleLogStub = sinon.spy(console, "log");
});
after(function () {
console.log.restore();
});
it("should be a function", function () {
assert.isDefined(info);
});
it("should have a getVersion method", function () {
assert.isDefined(info.getVersion);
});
it("should return the correct version number (1)", function () {
var pjson = {
version: "2.0"
};
var actual = info.getVersion(pjson);
assert.equal(actual, "2.0");
});
it("should return the correct version number (2)", function () {
var pjson = {
version: "3.0"
};
var actual = info.getVersion(pjson);
assert.equal(actual, "3.0");
});
it("should log the version to the console", function () {
var pjson = {
version: "3.0"
};
info.getVersion(pjson);
sinon.assert.calledWithExactly(consoleLogStub, "3.0");
});
});
describe("When creating the config file:", function () {
var readStub;
var writeStub;
var consoleStub;
before(function () {
readStub = sinon.stub(fs, "readFileSync").returns("DATA");
writeStub = sinon.stub(fs, "writeFile").yields(null);
consoleStub = sinon.spy(console, "log");
});
after(function () {
fs.writeFile.restore();
fs.readFileSync.restore();
console.log.restore();
});
it("should call the readFileSync method", function (done) {
info.makeConfig("/Users/shakyshane", function () {
sinon.assert.called(readStub);
done();
});
});
});
});