Created
July 26, 2020 20:43
-
-
Save chelseatroy/9b350562a1bac37b9536373eb8ac4791 to your computer and use it in GitHub Desktop.
Service Integration Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BlogPostServiceTests.swift | |
// ScottishGaelicTattooHandbookTests | |
// | |
// Created by Chelsea Troy on 7/26/20. | |
// Copyright © 2020 Chelsea Troy. All rights reserved. | |
// | |
import XCTest | |
@testable import ScottishGaelicTattooHandbook | |
class BlogPostServiceTests: XCTestCase { | |
var systemUnderTest: BlogPostService! | |
override func setUp() { | |
self.systemUnderTest = BlogPostService() | |
} | |
override func tearDown() { | |
self.systemUnderTest = nil | |
} | |
func testAPI_returnsSuccessfulResult() { | |
//Given | |
var blogPosts: [BlogPost]! | |
var error: Error? | |
let promise = expectation(description: "Completion handler is invoked") | |
//When | |
self.systemUnderTest.getBlogPosts(completion: { data, shouldntHappen in | |
blogPosts = data | |
error = shouldntHappen | |
promise.fulfill() | |
}) | |
wait(for: [promise], timeout: 5) | |
//Then | |
XCTAssertNotNil(blogPosts) | |
XCTAssertEqual(blogPosts.count, 3) | |
for post in blogPosts { | |
XCTAssertNotNil(post.title.rendered) | |
XCTAssertNotNil(post.imageURL) | |
} | |
XCTAssertNil(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment