forked from jaguar07/Swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVFoundationQRcodeTests.swift
More file actions
49 lines (37 loc) · 1.42 KB
/
Copy pathAVFoundationQRcodeTests.swift
File metadata and controls
49 lines (37 loc) · 1.42 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
//
// AVFoundationQRcodeTests.swift
// AVFoundationQRcodeTests
//
// Created by Carlos Butron on 01/01/2018.
// Copyright © 2018 Carlos Butron. All rights reserved.
//
import UIKit
import XCTest
@testable import AVFoundationQRcode
class AVFoundationQRcodeTests: XCTestCase {
var sut: ViewController!
var mockCodeReader: MockCodeReader!
override func setUp() {
super.setUp()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let nav = storyboard.instantiateInitialViewController() as? UINavigationController
sut = nav?.viewControllers.first as? ViewController
mockCodeReader = MockCodeReader()
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func test_givenViewController_whenLoaded_thenAddVideoPreviewLayer() {
sut.codeReader = mockCodeReader
sut.loadViewIfNeeded()
XCTAssertTrue(sut.previewView.layer.sublayers?.contains(mockCodeReader.videoPreview) ?? false)
}
func test_givenViewController_whenReadCode_thenUpdateUrl() {
sut.codeReader = mockCodeReader
sut.loadViewIfNeeded()
sut.viewDidAppear(false)
mockCodeReader.completion?(.success("www.mockurl.com"))
XCTAssertEqual(sut.sendURL, "www.mockurl.com")
}
}