Skip to content

Commit

Permalink
chore(app): unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Nov 17, 2024
1 parent 019b56f commit c2f42df
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,25 @@ enum RouteType {
case .train: .gray
}
}

var rawValue: String {
switch self {
case .fallback:
"Fallback"
case let .metro(line):
line.rawValue
case .night:
"Night"
case .bus:
"Bus"
case .tram:
"Tram"
case .ferry:
"Ferry"
case .funicular:
"Funicular"
case .train:
"Train"
}
}
}
2 changes: 1 addition & 1 deletion apps/mobile/metro-now/common/utils/station.utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func shortenStopName(_ stop: String) -> String {
if stop.hasPrefix("Náměstí") {
return stop.replacingOccurrences(of: "Náměstí", with: "Nám.")
} else if stop.hasSuffix("náměstí") {
return stop.replacingOccurrences(of: "náměstí", with: "nám")
return stop.replacingOccurrences(of: "náměstí", with: "nám.")
}

return stop
Expand Down
137 changes: 136 additions & 1 deletion apps/mobile/metro-now/metro-now.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
remoteGlobalIDString = 2D001BB72CC8099C00C6B4F8;
remoteInfo = "metro-now Watch App";
};
2D7FEC7B2CE96F300073FF5B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2D001BA02CC8099B00C6B4F8 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 2D001BA72CC8099B00C6B4F8;
remoteInfo = "metro-now";
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -39,9 +46,24 @@
/* Begin PBXFileReference section */
2D001BA82CC8099B00C6B4F8 /* metro-now.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "metro-now.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D001BB82CC8099C00C6B4F8 /* metro-now Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "metro-now Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D7FEC772CE96F300073FF5B /* metro-nowTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "metro-nowTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
2D7FEC812CE96F830073FF5B /* Exceptions for "common" folder in "metro-nowTests" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
"components/countdown-view/countdown.utils.swift",
"components/route-label-view/get-color-by-route-name.utils.swift",
"components/route-label-view/route-type.enum.swift",
const/endpoint.const.swift,
"types/api-types.swift",
utils/array.utils.swift,
"utils/get-platform-label.swift",
utils/station.utils.swift,
);
target = 2D7FEC762CE96F300073FF5B /* metro-nowTests */;
};
2D9601C92CC812EF000EF3D5 /* Exceptions for "common" folder in "metro-now Watch App" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Expand All @@ -54,6 +76,7 @@
"types/api-types.swift",
utils/array.utils.swift,
"utils/find-closest-stop.swift",
"utils/get-platform-label.swift",
utils/station.utils.swift,
);
target = 2D001BB72CC8099C00C6B4F8 /* metro-now Watch App */;
Expand All @@ -71,10 +94,16 @@
path = "metro-now Watch App";
sourceTree = "<group>";
};
2D7FEC782CE96F300073FF5B /* metro-nowTests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = "metro-nowTests";
sourceTree = "<group>";
};
2D9601C12CC8126F000EF3D5 /* common */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
2D9601C92CC812EF000EF3D5 /* Exceptions for "common" folder in "metro-now Watch App" target */,
2D7FEC812CE96F830073FF5B /* Exceptions for "common" folder in "metro-nowTests" target */,
);
path = common;
sourceTree = "<group>";
Expand All @@ -98,6 +127,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
2D7FEC742CE96F300073FF5B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -107,6 +143,7 @@
2D9601C12CC8126F000EF3D5 /* common */,
2D001BAA2CC8099B00C6B4F8 /* metro-now */,
2D001BBC2CC8099C00C6B4F8 /* metro-now Watch App */,
2D7FEC782CE96F300073FF5B /* metro-nowTests */,
2D8EBE2C2CE93DC9004D5F5B /* Frameworks */,
2D001BA92CC8099B00C6B4F8 /* Products */,
);
Expand All @@ -117,6 +154,7 @@
children = (
2D001BA82CC8099B00C6B4F8 /* metro-now.app */,
2D001BB82CC8099C00C6B4F8 /* metro-now Watch App.app */,
2D7FEC772CE96F300073FF5B /* metro-nowTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -180,14 +218,37 @@
productReference = 2D001BB82CC8099C00C6B4F8 /* metro-now Watch App.app */;
productType = "com.apple.product-type.application";
};
2D7FEC762CE96F300073FF5B /* metro-nowTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 2D7FEC7F2CE96F300073FF5B /* Build configuration list for PBXNativeTarget "metro-nowTests" */;
buildPhases = (
2D7FEC732CE96F300073FF5B /* Sources */,
2D7FEC742CE96F300073FF5B /* Frameworks */,
2D7FEC752CE96F300073FF5B /* Resources */,
);
buildRules = (
);
dependencies = (
2D7FEC7C2CE96F300073FF5B /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
2D7FEC782CE96F300073FF5B /* metro-nowTests */,
);
name = "metro-nowTests";
packageProductDependencies = (
);
productName = "metro-nowTests";
productReference = 2D7FEC772CE96F300073FF5B /* metro-nowTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
2D001BA02CC8099B00C6B4F8 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastSwiftUpdateCheck = 1610;
LastUpgradeCheck = 1610;
TargetAttributes = {
2D001BA72CC8099B00C6B4F8 = {
Expand All @@ -196,6 +257,10 @@
2D001BB72CC8099C00C6B4F8 = {
CreatedOnToolsVersion = 16.0;
};
2D7FEC762CE96F300073FF5B = {
CreatedOnToolsVersion = 16.1;
TestTargetID = 2D001BA72CC8099B00C6B4F8;
};
};
};
buildConfigurationList = 2D001BA32CC8099B00C6B4F8 /* Build configuration list for PBXProject "metro-now" */;
Expand All @@ -217,6 +282,7 @@
targets = (
2D001BA72CC8099B00C6B4F8 /* metro-now */,
2D001BB72CC8099C00C6B4F8 /* metro-now Watch App */,
2D7FEC762CE96F300073FF5B /* metro-nowTests */,
);
};
/* End PBXProject section */
Expand All @@ -236,6 +302,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
2D7FEC752CE96F300073FF5B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -253,6 +326,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
2D7FEC732CE96F300073FF5B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand All @@ -261,6 +341,11 @@
target = 2D001BB72CC8099C00C6B4F8 /* metro-now Watch App */;
targetProxy = 2D001BBA2CC8099C00C6B4F8 /* PBXContainerItemProxy */;
};
2D7FEC7C2CE96F300073FF5B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 2D001BA72CC8099B00C6B4F8 /* metro-now */;
targetProxy = 2D7FEC7B2CE96F300073FF5B /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -514,6 +599,47 @@
};
name = Release;
};
2D7FEC7D2CE96F300073FF5B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = R6WU5ABNG2;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.1;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-nowTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/metro-now.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/metro-now";
};
name = Debug;
};
2D7FEC7E2CE96F300073FF5B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = R6WU5ABNG2;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.1;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.krystof.metro-nowTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/metro-now.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/metro-now";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -544,6 +670,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
2D7FEC7F2CE96F300073FF5B /* Build configuration list for PBXNativeTarget "metro-nowTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
2D7FEC7D2CE96F300073FF5B /* Debug */,
2D7FEC7E2CE96F300073FF5B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D7FEC762CE96F300073FF5B"
BuildableName = "metro-nowTests.xctest"
BlueprintName = "metro-nowTests"
ReferencedContainer = "container:metro-now.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2D7FEC762CE96F300073FF5B"
BuildableName = "metro-nowTests.xctest"
BlueprintName = "metro-nowTests"
ReferencedContainer = "container:metro-now.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down
18 changes: 18 additions & 0 deletions apps/mobile/metro-now/metro-nowTests/endpoint.test.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// metro-now
// https://github.com/krystxf/metro-now

import Foundation
import Testing

@Test("ENDPOINT")
func endpoint() async throws {
#expect(
!ENDPOINT.contains("localhost"),
"ENDPOINT should not contain localhost"
)

#expect(
URL(string: ENDPOINT) != nil,
"ENDPOINT should be valid URL"
)
}
Loading

0 comments on commit c2f42df

Please sign in to comment.