From 93e8b7853f4f3fbe57630262445d71273a18cd7e Mon Sep 17 00:00:00 2001 From: lukakerr Date: Mon, 25 Mar 2019 20:39:58 +1100 Subject: [PATCH] Add URL tests, remove unused setup and teardown --- Pine.xcodeproj/project.pbxproj | 12 ++++--- PineTests/NSColorTests.swift | 8 ----- ...tViewTests.swift => NSTextViewTests.swift} | 4 +-- PineTests/StringTests.swift | 8 ----- PineTests/URLTests.swift | 33 +++++++++++++++++++ 5 files changed, 43 insertions(+), 22 deletions(-) rename PineTests/{TextViewTests.swift => NSTextViewTests.swift} (98%) create mode 100644 PineTests/URLTests.swift diff --git a/Pine.xcodeproj/project.pbxproj b/Pine.xcodeproj/project.pbxproj index 1313f08..01a3d7d 100644 --- a/Pine.xcodeproj/project.pbxproj +++ b/Pine.xcodeproj/project.pbxproj @@ -32,7 +32,7 @@ A156AF852090606C0098BBDD /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AF842090606C0098BBDD /* Document.swift */; }; A156AF872090606C0098BBDD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A156AF862090606C0098BBDD /* Assets.xcassets */; }; A156AF8A2090606D0098BBDD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A156AF882090606D0098BBDD /* Main.storyboard */; }; - A156AF962090606D0098BBDD /* TextViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AF952090606D0098BBDD /* TextViewTests.swift */; }; + A156AF962090606D0098BBDD /* NSTextViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AF952090606D0098BBDD /* NSTextViewTests.swift */; }; A156AFA12090606D0098BBDD /* InitialOpenUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AFA02090606D0098BBDD /* InitialOpenUITests.swift */; }; A156AFAF209061D60098BBDD /* PineWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AFAE209061D60098BBDD /* PineWindowController.swift */; }; A156AFB120908ECE0098BBDD /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = A156AFB020908ECE0098BBDD /* Theme.swift */; }; @@ -69,6 +69,7 @@ A1C40210221F868200E3DBCC /* ReferenceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C4020F221F868200E3DBCC /* ReferenceViewController.swift */; }; A1C65D82221179230053C422 /* DocumentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C65D81221179230053C422 /* DocumentController.swift */; }; A1C65FB620DE2B0D00326C60 /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C65FB520DE2B0D00326C60 /* Alert.swift */; }; + A1CB4A0C2248D80300CA10A9 /* URLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1CB4A0B2248D80300CA10A9 /* URLTests.swift */; }; A1CFDA6E223D04D800ECFFA7 /* Autocomplete.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1CFDA6D223D04D800ECFFA7 /* Autocomplete.swift */; }; A1D4A0382234C77A00E2159A /* SidebarTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D4A0372234C77A00E2159A /* SidebarTableRowView.swift */; }; A1D5466420D4D9CC00D1221A /* Exporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D5466320D4D9CC00D1221A /* Exporter.swift */; }; @@ -133,7 +134,7 @@ A156AF892090606D0098BBDD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; A156AF8B2090606D0098BBDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A156AF912090606D0098BBDD /* PineTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PineTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - A156AF952090606D0098BBDD /* TextViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewTests.swift; sourceTree = ""; }; + A156AF952090606D0098BBDD /* NSTextViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSTextViewTests.swift; sourceTree = ""; }; A156AF972090606D0098BBDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A156AF9C2090606D0098BBDD /* PineUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PineUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A156AFA02090606D0098BBDD /* InitialOpenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialOpenUITests.swift; sourceTree = ""; }; @@ -173,6 +174,7 @@ A1C4020F221F868200E3DBCC /* ReferenceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReferenceViewController.swift; sourceTree = ""; }; A1C65D81221179230053C422 /* DocumentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentController.swift; sourceTree = ""; }; A1C65FB520DE2B0D00326C60 /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = ""; }; + A1CB4A0B2248D80300CA10A9 /* URLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLTests.swift; sourceTree = ""; }; A1CFDA6D223D04D800ECFFA7 /* Autocomplete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Autocomplete.swift; sourceTree = ""; }; A1D4A0372234C77A00E2159A /* SidebarTableRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarTableRowView.swift; sourceTree = ""; }; A1D5466320D4D9CC00D1221A /* Exporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Exporter.swift; sourceTree = ""; }; @@ -357,7 +359,8 @@ A156AF972090606D0098BBDD /* Info.plist */, A1767B05220FC44D00ED1A61 /* NSColorTests.swift */, A1767B03220FC2DD00ED1A61 /* StringTests.swift */, - A156AF952090606D0098BBDD /* TextViewTests.swift */, + A156AF952090606D0098BBDD /* NSTextViewTests.swift */, + A1CB4A0B2248D80300CA10A9 /* URLTests.swift */, ); path = PineTests; sourceTree = ""; @@ -762,7 +765,8 @@ files = ( A1767B06220FC44D00ED1A61 /* NSColorTests.swift in Sources */, A1767B04220FC2DD00ED1A61 /* StringTests.swift in Sources */, - A156AF962090606D0098BBDD /* TextViewTests.swift in Sources */, + A156AF962090606D0098BBDD /* NSTextViewTests.swift in Sources */, + A1CB4A0C2248D80300CA10A9 /* URLTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PineTests/NSColorTests.swift b/PineTests/NSColorTests.swift index 59b34c6..fa519d6 100644 --- a/PineTests/NSColorTests.swift +++ b/PineTests/NSColorTests.swift @@ -11,14 +11,6 @@ import XCTest class NSColorTests: XCTestCase { - override func setUp() { - super.setUp() - } - - override func tearDown() { - super.tearDown() - } - func testIsDark() { let color = NSColor.black diff --git a/PineTests/TextViewTests.swift b/PineTests/NSTextViewTests.swift similarity index 98% rename from PineTests/TextViewTests.swift rename to PineTests/NSTextViewTests.swift index 3b960ae..cf35d5c 100644 --- a/PineTests/TextViewTests.swift +++ b/PineTests/NSTextViewTests.swift @@ -1,5 +1,5 @@ // -// TextViewTests.swift +// NSTextViewTests.swift // PineTests // // Created by Luka Kerr on 25/4/18. @@ -10,7 +10,7 @@ import XCTest import Cocoa @testable import Pine -class TextViewTests: XCTestCase { +class NSTextViewTests: XCTestCase { var textView: NSTextView! diff --git a/PineTests/StringTests.swift b/PineTests/StringTests.swift index 2c99178..a6a3b3c 100644 --- a/PineTests/StringTests.swift +++ b/PineTests/StringTests.swift @@ -11,14 +11,6 @@ import XCTest class StringTexts: XCTestCase { - override func setUp() { - super.setUp() - } - - override func tearDown() { - super.tearDown() - } - func testIsMarkdown() { let str = "MyFile.md" diff --git a/PineTests/URLTests.swift b/PineTests/URLTests.swift new file mode 100644 index 0000000..3d8a031 --- /dev/null +++ b/PineTests/URLTests.swift @@ -0,0 +1,33 @@ +// +// URLTests.swift +// PineTests +// +// Created by Luka Kerr on 25/3/19. +// Copyright © 2019 Luka Kerr. All rights reserved. +// + +import XCTest +@testable import Pine + +class URLTests: XCTestCase { + + func testIsImage() { + let url = URL(fileURLWithPath: "~/Desktop/pic.png") + + XCTAssertTrue(url.isImage) + } + + func testIsRelativeImage() { + let url = URL(fileURLWithPath: "../../image.jpeg") + + XCTAssertTrue(url.isImage) + } + + func testIsNotImage() { + let url = URL(fileURLWithPath: "./file.txt") + + XCTAssertFalse(url.isImage) + } + +} +