-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile-reader-spec.js
70 lines (44 loc) · 1.38 KB
/
file-reader-spec.js
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
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var expect = chai.expect;
describe("reader", function() {
var subject;
beforeEach(function() {
subject = require('./file-reader');
});
describe("#readFile()", function() {
context("when reading a valid file", function() {
var promise;
beforeEach(function() {
promise = subject.readFile("file1");
});
it("fulfills the promise", function() {
return expect(promise).to.be.fulfilled;
});
it("fulfills the promise with the contents of the file", function() {
return expect(promise).to.eventually.equal('Alice\n');
});
});
context("when reading an invalid file", function() {
var promise;
beforeEach(function() {
promise = subject.readFile("file42");
});
it("rejects the promise", function() {
return expect(promise).to.be.rejected;
});
it("rejects the promise with an file not found error", function() {
return expect(promise).to.be.rejectedWith("Error: ENOENT, open 'file42'");
});
});
});
});
describe("vente skinny iced chai pumpkin mocha latte", function() {
it("knows what is true", function() {
expect(true).to.be.true;
});
it("knows what is foo", function() {
expect("foo").to.equal("foo");
});
});