1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-19 08:57:35 +03:00
Macaw/MacawTests/SVGParserTest.swift
Julius Lundang 362d2a6f12 👌 Updating code due to code review changes.
* Updated SVGParserError to conform to Equatable so we can throwing functions
2018-08-19 17:04:28 +08:00

44 lines
1.5 KiB
Swift

//
// SVGParserTest.swift
// MacawTests
//
// Created by Julius Lundang on 19/08/2018.
// Copyright © 2018 Exyte. All rights reserved.
//
import XCTest
@testable import Macaw
class SVGParserTest: XCTestCase {
func testParseFromOtherBundle() {
let bundle = Bundle(for: type(of: TestUtils()))
let bundleMacawTestsURL = bundle.resourceURL?.appendingPathComponent("MacawTests.bundle")
let macawTestsBundle = Bundle(url: bundleMacawTestsURL!)!
do {
let node = try SVGParser.parse(resource: "circle", fromBundle: macawTestsBundle)
XCTAssertNotNil(node)
if let fullPath = macawTestsBundle.path(forResource: "circle", ofType: "svg") {
let node2 = try SVGParser.parse(fullPath: fullPath)
XCTAssertNotNil(node2)
} else {
XCTFail("No circle.svg found")
}
} catch {
XCTFail(error.localizedDescription)
}
}
func testParseGivenInvalidPath() {
let fullPath = "invalid fullPath"
XCTAssertThrowsError(try SVGParser.parse(fullPath: fullPath)) { error in
XCTAssertEqual(error as! SVGParserError, SVGParserError.noSuchFile(path: "invalid fullPath"))
}
}
func testParseGiventEmptyPath() {
XCTAssertThrowsError(try SVGParser.parse(fullPath: "")) { error in
XCTAssertEqual(error as! SVGParserError, SVGParserError.noSuchFile(path: ""))
}
}
}