Skip to content

Commit 4389a97

Browse files
author
Daniel Große
committed
Adds test for mimeTypes
1 parent f4f7f8e commit 4389a97

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

XCode/Swifter.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
269B47981D3AAAE20042D137 /* Errno.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76B2A11D369C9D00D35BFB /* Errno.swift */; };
3131
269B47991D3AAAE20042D137 /* String+BASE64.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C76B6F61D2C44F30030FC98 /* String+BASE64.swift */; };
3232
269B47A71D3AAC4F0042D137 /* SwiftertvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 269B47A51D3AAC4F0042D137 /* SwiftertvOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
33+
6A0D4512204E9988000A0726 /* MimeTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4511204E9988000A0726 /* MimeTypesTests.swift */; };
34+
6A0D4513204E9988000A0726 /* MimeTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A0D4511204E9988000A0726 /* MimeTypesTests.swift */; };
3335
6AE2FF722048013000302EC4 /* MimeTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE2FF702048011A00302EC4 /* MimeTypes.swift */; };
3436
6AE2FF732048013000302EC4 /* MimeTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE2FF702048011A00302EC4 /* MimeTypes.swift */; };
3537
6AE2FF742048013100302EC4 /* MimeTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE2FF702048011A00302EC4 /* MimeTypes.swift */; };
@@ -155,6 +157,7 @@
155157
269B47A11D3AAAE20042D137 /* Swifter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Swifter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
156158
269B47A41D3AAC4F0042D137 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
157159
269B47A51D3AAC4F0042D137 /* SwiftertvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftertvOS.h; sourceTree = "<group>"; };
160+
6A0D4511204E9988000A0726 /* MimeTypesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MimeTypesTests.swift; sourceTree = "<group>"; };
158161
6AE2FF702048011A00302EC4 /* MimeTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MimeTypes.swift; sourceTree = "<group>"; };
159162
7AE893E71C05127900A29F63 /* Swifter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Swifter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
160163
7AE893E91C05127900A29F63 /* SwifteriOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwifteriOS.h; sourceTree = "<group>"; };
@@ -374,6 +377,7 @@
374377
7CCD876E1C660B250068099B /* SwifterTestsStringExtensions.swift */,
375378
7C4785E81C71D15600A9FE73 /* SwifterTestsWebSocketSession.swift */,
376379
0858E7F31D68BB2600491CD1 /* IOSafetyTests.swift */,
380+
6A0D4511204E9988000A0726 /* MimeTypesTests.swift */,
377381
);
378382
path = SwifterTestsCommon;
379383
sourceTree = "<group>";
@@ -762,6 +766,7 @@
762766
buildActionMask = 2147483647;
763767
files = (
764768
7CCD87701C660B250068099B /* SwifterTestsHttpParser.swift in Sources */,
769+
6A0D4512204E9988000A0726 /* MimeTypesTests.swift in Sources */,
765770
6AE2FF752048013300302EC4 /* MimeTypes.swift in Sources */,
766771
0858E7F81D68BC2600491CD1 /* PingServer.swift in Sources */,
767772
0858E7F41D68BB2600491CD1 /* IOSafetyTests.swift in Sources */,
@@ -789,6 +794,7 @@
789794
7CEBB8781D94612D00370A6B /* Socket.swift in Sources */,
790795
7CEBB8791D94612D00370A6B /* Socket+File.swift in Sources */,
791796
7CEBB87A1D94612D00370A6B /* Socket+Server.swift in Sources */,
797+
6A0D4513204E9988000A0726 /* MimeTypesTests.swift in Sources */,
792798
7CEBB87B1D94612D00370A6B /* String+BASE64.swift in Sources */,
793799
7CEBB87C1D94612D00370A6B /* String+Misc.swift in Sources */,
794800
7CEBB87D1D94612D00370A6B /* String+SHA1.swift in Sources */,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// MimeTypesTests.swift
3+
// Swifter
4+
//
5+
// Created by Daniel Große on 06.03.18.
6+
// Copyright © 2018 Damian Kołakowski. All rights reserved.
7+
//
8+
9+
import XCTest
10+
11+
class MimeTypeTests: XCTestCase {
12+
13+
func testTypeExtension() {
14+
XCTAssertNotNil(String.mimeType, "Type String is extended with mimeType")
15+
XCTAssertNotNil(NSURL.mimeType, "Type NSURL is extended with mimeType")
16+
XCTAssertNotNil(NSString.mimeType, "Type NSString is extended with mimeType")
17+
}
18+
19+
func testDefaultValue() {
20+
XCTAssertEqual("file.null".mimeType(), "application/octet-stream")
21+
}
22+
23+
func testCorrectTypes() {
24+
XCTAssertEqual("file.html".mimeType(), "text/html")
25+
XCTAssertEqual("file.css".mimeType(), "text/css")
26+
XCTAssertEqual("file.mp4".mimeType(), "video/mp4")
27+
XCTAssertEqual("file.pptx".mimeType(), "application/vnd.openxmlformats-officedocument.presentationml.presentation")
28+
XCTAssertEqual("file.war".mimeType(), "application/java-archive")
29+
}
30+
31+
func testCaseInsensitivity() {
32+
XCTAssertEqual("file.HTML".mimeType(), "text/html")
33+
XCTAssertEqual("file.cSs".mimeType(), "text/css")
34+
XCTAssertEqual("file.MP4".mimeType(), "video/mp4")
35+
XCTAssertEqual("file.PPTX".mimeType(), "application/vnd.openxmlformats-officedocument.presentationml.presentation")
36+
XCTAssertEqual("FILE.WAR".mimeType(), "application/java-archive")
37+
}
38+
39+
}
40+

0 commit comments

Comments
 (0)