Skip to content

Commit a08c232

Browse files
committed
Add unit tests for optional string + isNilOrEmpty.
1 parent 213d3c4 commit a08c232

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
024DF32123744798006658FE /* AztecFormatBarCommandCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024DF32023744798006658FE /* AztecFormatBarCommandCoordinator.swift */; };
129129
024EFA6923FCC10B00F36918 /* Product+Media.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024EFA6823FCC10B00F36918 /* Product+Media.swift */; };
130130
02521E11243DC3C400DC7810 /* CancellableMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02521E10243DC3C400DC7810 /* CancellableMedia.swift */; };
131+
02564A88246C047C00D6DB2A /* Optional+StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02564A87246C047C00D6DB2A /* Optional+StringTests.swift */; };
131132
0257285C230ACC7E00A288C4 /* StoreStatsV4ChartAxisHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0257285B230ACC7E00A288C4 /* StoreStatsV4ChartAxisHelperTests.swift */; };
132133
025B1748237A92D800C780B4 /* ProductFormSection+ReusableTableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025B1747237A92D800C780B4 /* ProductFormSection+ReusableTableRow.swift */; };
133134
025B174A237AA49D00C780B4 /* Product+ProductForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025B1749237AA49D00C780B4 /* Product+ProductForm.swift */; };
@@ -966,6 +967,7 @@
966967
024DF32023744798006658FE /* AztecFormatBarCommandCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AztecFormatBarCommandCoordinator.swift; sourceTree = "<group>"; };
967968
024EFA6823FCC10B00F36918 /* Product+Media.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Product+Media.swift"; sourceTree = "<group>"; };
968969
02521E10243DC3C400DC7810 /* CancellableMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CancellableMedia.swift; sourceTree = "<group>"; };
970+
02564A87246C047C00D6DB2A /* Optional+StringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+StringTests.swift"; sourceTree = "<group>"; };
969971
0257285B230ACC7E00A288C4 /* StoreStatsV4ChartAxisHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreStatsV4ChartAxisHelperTests.swift; sourceTree = "<group>"; };
970972
025B1747237A92D800C780B4 /* ProductFormSection+ReusableTableRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductFormSection+ReusableTableRow.swift"; sourceTree = "<group>"; };
971973
025B1749237AA49D00C780B4 /* Product+ProductForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Product+ProductForm.swift"; sourceTree = "<group>"; };
@@ -2968,6 +2970,7 @@
29682970
0215320C2423309B003F2BBD /* UIStackView+SubviewsTests.swift */,
29692971
6856D7981E11F85D5E4EFED7 /* NSMutableAttributedStringHelperTests.swift */,
29702972
5761298A24589B84007BB2D9 /* NumberFormatter+LocalizedOrNinetyNinePlusTests.swift */,
2973+
02564A87246C047C00D6DB2A /* Optional+StringTests.swift */,
29712974
);
29722975
path = Extensions;
29732976
sourceTree = "<group>";
@@ -4941,6 +4944,7 @@
49414944
0247AAA223A3C5A6007F967E /* DecimalInputFormatterTests.swift in Sources */,
49424945
B509FED521C052D1000076A9 /* MockupSupportManager.swift in Sources */,
49434946
02691782232605B9002AFC20 /* PaginatedListViewControllerStateCoordinatorTests.swift in Sources */,
4947+
02564A88246C047C00D6DB2A /* Optional+StringTests.swift in Sources */,
49444948
0269576D23726401001BA0BF /* KeyboardFrameObserverTests.swift in Sources */,
49454949
0215320D2423309B003F2BBD /* UIStackView+SubviewsTests.swift in Sources */,
49464950
027B8BBD23FE0DE10040944E /* ProductImageActionHandlerTests.swift in Sources */,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import XCTest
2+
@testable import WooCommerce
3+
4+
final class Optional_StringTests: XCTestCase {
5+
// MARK: - `isNilOrEmpty`
6+
7+
func testNilStringReturnsTrueForNilOrEmpty() {
8+
let string: String? = nil
9+
XCTAssertTrue(string.isNilOrEmpty)
10+
}
11+
12+
func testEmptyStringReturnsTrueForNilOrEmpty() {
13+
let string: String? = ""
14+
XCTAssertTrue(string.isNilOrEmpty)
15+
}
16+
17+
func testNonEmptyStringReturnsFalseForNilOrEmpty() {
18+
let string: String? = "🤓"
19+
XCTAssertFalse(string.isNilOrEmpty)
20+
}
21+
}

0 commit comments

Comments
 (0)