Skip to content

Commit

Permalink
Merge branch 'develop' into fix/sopt-makers#348-Poke-2차-QA-반영
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Jan 8, 2024
2 parents 059833e + 01dac62 commit b0b74c9
Show file tree
Hide file tree
Showing 12 changed files with 933 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public struct HomeDeepLink: DeepLinkExecutable {
public func execute(with coordinator: Coordinator, queryItems: [URLQueryItem]?) -> Coordinator? {
guard let coordinator = coordinator as? ApplicationCoordinator else { return nil }

coordinator.runMainFlow()
if self.isDestination == true {
coordinator.runMainFlow()
}

return coordinator
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ public class DeepLinkComponents: DeepLinkComponentsExecutable {

// deepLink 배열을 재귀적으로 돌며 각 단계의 딥링크 뷰로 이동시킨다.
public func execute(coordinator: Coordinator) {
guard let firstDeepLink = popFirstDeepLink() else { return }

if firstDeepLink.name == "home" && self.isEmpty {
firstDeepLink.execute(with: coordinator, queryItems: self.queryItems)
return
}

var nextCoordinator: Coordinator? = coordinator
while !self.isEmpty, let coordinator = nextCoordinator {
let deepLink = popFirstDeepLink()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Simulator Target Bundle" : "com.sopt-stamp-iOS.test",
"aps" : {
"alert" : {
"title" : "테스트",
"body" : "안녕하세요",
},
},
"category": "NOTICE",
"deepLink": "home/soptamp/entire-ranking",
"id": "2133"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Simulator Target Bundle" : "com.sopt-stamp-iOS.test",
"aps" : {
"alert" : {
"title" : "웹링크 테스트",
"body" : "웹링크 바디",
},
},
"category": "NOTICE",
"webLink": "https://www.sopt.org",
"id": "6677"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
//
// DeepLinkComponentsTests.swift
// RootFeatureTests
//
// Created by sejin on 1/2/24.
// Copyright © 2024 SOPT-iOS. All rights reserved.
//

import XCTest
import Combine

import BaseFeatureDependency
@testable import RootFeature

final class DeepLinkComponentsTests: XCTestCase {
private var deepLinkComponents: DeepLinkComponents!

override func setUp() {
super.setUp()
self.deepLinkComponents = DeepLinkComponents(deepLinkData: self.mockDeepLinkData)
}

override func tearDown() {
super.tearDown()
self.deepLinkComponents = nil
}

func test_nil인_데이터로_init을_수행한다() {
// Given
let data: DeepLinkData? = nil

// When
let deepLinkComponents = DeepLinkComponents(deepLinkData: data)

// Then
XCTAssertNil(deepLinkComponents)
}

func test_딥링크_데이터가_존재하는_경우_isEmpty를_검사() {
// Given
let expected = false

// When
let result = deepLinkComponents.isEmpty

// Then
XCTAssertEqual(expected, result)
}

func test_isEmpty_빈_딥링크_배열인_경우() {
// Given
let expected = true
let deepLinkComponents = DeepLinkComponents(deepLinkData: ([], nil))

// When
let result = deepLinkComponents.isEmpty

// Then
XCTAssertEqual(expected, result)
}

func test_queryItems_할당() {
// Given
let expected = self.mockDeepLinkData.queryItems

// When
let result = deepLinkComponents.queryItems

// Then
XCTAssertEqual(expected, result)
}

func test_id가_키인_쿼리데이터를_가져온다() {
// Given
let expected = "123"

// When
let result = deepLinkComponents.getQueryItemValue(name: "id")

// Then
XCTAssertEqual(expected, result)
}

func test_쿼리_배열이_비어있는_경우_id_쿼리찾기() {
// Given
let expected: String? = nil
let deepLinkComponents = DeepLinkComponents(deepLinkData: ([], nil))

// When
let result = deepLinkComponents.getQueryItemValue(name: "id")

// Then
XCTAssertEqual(expected, result)
}

func test_찾는_쿼리가_없는_경우에_쿼리아이템을_요청한다() {
// Given
let expected: String? = nil

// When
let result = deepLinkComponents.getQueryItemValue(name: "weirdKey")

// Then
XCTAssertEqual(expected, result)
}

func test_새_딥링크_객체를_추가한다() {
// Given
let deepLinkComponents = DeepLinkComponents(deepLinkData: ([], nil))

// When
deepLinkComponents.addDeepLink(HomeDeepLink())

// Then
XCTAssertFalse(deepLinkComponents.isEmpty)
}

func test_딥링크_구현체들을_execute하여_라우팅을_수행한다() {
// Given
let coordinator = MockCoordinator()
let mockDeepLinks: [DeepLinkExecutable] = [MockHomeDeepLink(), MockSoptampDeepLink()]
let expected = mockDeepLinks.map { $0.name }

// When
let deepLinkComponents = DeepLinkComponents(deepLinkData: (mockDeepLinks, nil))
deepLinkComponents.execute(coordinator: coordinator)

// Then
XCTAssertEqual(expected, coordinator.childViewNames)
}
}

extension DeepLinkComponentsTests {
private var mockDeepLinkData: DeepLinkData {
return (deepLinks: [HomeDeepLink(), NotificationDeepLink()], queryItems: [URLQueryItem(name: "id", value: "123"), URLQueryItem(name: "status", value: "active")])
}
}
Loading

0 comments on commit b0b74c9

Please sign in to comment.