mirror of
https://github.com/mas-cli/mas
synced 2024-11-25 13:00:23 +00:00
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
//
|
|
// OutputListenerSpec.swift
|
|
// MasKitTests
|
|
//
|
|
// Created by Ben Chatelain on 1/8/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
|
|
import Nimble
|
|
import Quick
|
|
|
|
class OutputListenerSpec: QuickSpec {
|
|
override func spec() {
|
|
xdescribe("output listener") {
|
|
it("can intercept a single line written stdout") {
|
|
let output = OutputListener()
|
|
output.openConsolePipe()
|
|
|
|
let expectedOutput = "hi there"
|
|
|
|
print("hi there", terminator: "")
|
|
|
|
// output is async so need to wait for contents to be updated
|
|
expect(output.contents).toEventuallyNot(beEmpty())
|
|
expect(output.contents) == expectedOutput
|
|
|
|
output.closeConsolePipe()
|
|
}
|
|
it("can intercept multiple lines written stdout") {
|
|
let output = OutputListener()
|
|
output.openConsolePipe()
|
|
|
|
let expectedOutput = """
|
|
hi there
|
|
|
|
"""
|
|
|
|
print("hi there")
|
|
|
|
// output is async so need to wait for contents to be updated
|
|
expect(output.contents).toEventuallyNot(beEmpty())
|
|
expect(output.contents) == expectedOutput
|
|
|
|
output.closeConsolePipe()
|
|
}
|
|
}
|
|
}
|
|
}
|