forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture_spec.coffee
More file actions
55 lines (41 loc) · 1.26 KB
/
Copy pathcapture_spec.coffee
File metadata and controls
55 lines (41 loc) · 1.26 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
require("../spec_helper")
capture = require("#{root}lib/capture")
describe "lib/capture", ->
afterEach ->
capture.restore()
context "process.stdout.write", ->
beforeEach ->
@write = sinon.spy(process.stdout, "write")
@captured = capture.stdout()
it "slurps up stdout", ->
console.log("foo")
console.log("bar")
process.stdout.write("baz")
expect(@captured.data).to.deep.eq([
"foo\n"
"bar\n"
"baz"
])
expect(@captured.toString()).to.eq("foo\nbar\nbaz")
## should still call through to write
expect(@write).to.be.calledWith("foo\n")
expect(@write).to.be.calledWith("bar\n")
expect(@write).to.be.calledWith("baz")
context "process.log", ->
beforeEach ->
@log = process.log
@logStub = process.log = sinon.stub()
@captured = capture.stdout()
afterEach ->
process.log = @log
it "slurps up logs", ->
process.log("foo\n")
process.log("bar\n")
expect(@captured.data).to.deep.eq([
"foo\n"
"bar\n"
])
expect(@captured.toString()).to.eq("foo\nbar\n")
## should still call through to write
expect(@logStub).to.be.calledWith("foo\n")
expect(@logStub).to.be.calledWith("bar\n")