Skip to content

Commit

Permalink
👌 Updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
iujames authored and mmaatttt committed Apr 11, 2023
1 parent 77b6479 commit 9931240
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class AppcuesBackdropKeyholeTrait: BackdropDecoratingTrait {
let cornerRadius: Double?
let spreadRadius: Double?
}

static let type: String = "@appcues/backdrop-keyhole"

weak var metadataDelegate: TraitMetadataDelegate?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ internal class AppcuesModalTrait: StepDecoratingTrait, WrapperCreatingTrait, Pre
let style: ExperienceComponent.Style?
}

weak var metadataDelegate: TraitMetadataDelegate?

static let type = "@appcues/modal"

weak var metadataDelegate: TraitMetadataDelegate?

private let presentationStyle: PresentationStyle
private let modalStyle: ExperienceComponent.Style?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
internal class AppcuesStepTransitionAnimationTrait: ContainerDecoratingTrait {
struct Config: Decodable {
let duration: Double?
let easing: String?
let easing: Easing?
}

static var type: String = "@appcues/step-transition-animation"
Expand All @@ -24,7 +24,7 @@ internal class AppcuesStepTransitionAnimationTrait: ContainerDecoratingTrait {
required init?(configuration: ExperiencePluginConfiguration, level: ExperienceTraitLevel) {
let config = configuration.decode(Config.self)
self.duration = config?.duration ?? 0.3
self.easing = Easing(rawValue: config?.easing ?? "") ?? .linear
self.easing = config?.easing ?? .linear
}

func decorate(containerController: ExperienceContainerViewController) throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class AppcuesTargetRectangleTrait: BackdropDecoratingTrait {
let width: Double
let height: Double
}

static let type: String = "@appcues/target-rectangle"

weak var metadataDelegate: TraitMetadataDelegate?
Expand Down
12 changes: 2 additions & 10 deletions Tests/AppcuesKitTests/Actions/ActionRegistryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,8 @@ private extension ActionRegistryTests {
removeSubsequent: Bool? = nil) {
self.delay = delay
self.removeSubsequent = removeSubsequent
if let expectation = expectation {
self.executionExpectation = DecodableExpectation(expectation: expectation)
} else {
self.executionExpectation = nil
}
if let expectation2 = expectation2 {
self.executionExpectation2 = DecodableExpectation(expectation: expectation2)
} else {
self.executionExpectation2 = nil
}
self.executionExpectation = DecodableExpectation(expectation: expectation)
self.executionExpectation2 = DecodableExpectation(expectation: expectation2)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AppcuesCloseActionTests: XCTestCase {

func testInit() throws {
// Act
let action = AppcuesCloseAction()
let action = AppcuesCloseAction(configuration: ExperiencePluginConfiguration(nil))

// Assert
XCTAssertEqual(AppcuesCloseAction.type, "@appcues/close")
Expand Down
13 changes: 8 additions & 5 deletions Tests/AppcuesKitTests/Actions/AppcuesContinueActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ class AppcuesContinueActionTests: XCTestCase {

func testInit() throws {
// Act
let indexAction = AppcuesContinueAction(index: 1)
let offsetAction = AppcuesContinueAction(offset: -1)
let stepIDAction = AppcuesContinueAction(stepID: "8ebcb374-0eff-45a5-9d62-ffee52d8a57b")
let defaultAction = AppcuesContinueAction()

let indexAction = AppcuesContinueAction(
configuration: ExperiencePluginConfiguration(AppcuesContinueAction.Config(index: 1, offset: nil, stepID: nil)))
let offsetAction = AppcuesContinueAction(
configuration: ExperiencePluginConfiguration(AppcuesContinueAction.Config(index: nil, offset: -1, stepID: nil)))
let stepIDAction = AppcuesContinueAction(
configuration: ExperiencePluginConfiguration(AppcuesContinueAction.Config(index: nil, offset: nil, stepID: UUID(uuidString: "8ebcb374-0eff-45a5-9d62-ffee52d8a57b"))))
let defaultAction = AppcuesContinueAction(
configuration: ExperiencePluginConfiguration(nil))

// Assert
XCTAssertEqual(AppcuesContinueAction.type, "@appcues/continue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppcuesLaunchExperienceActionTests: XCTestCase {

func testInit() throws {
// Act
let action = AppcuesLaunchExperienceAction(experienceID: "123")
let action = AppcuesLaunchExperienceAction(configuration: ExperiencePluginConfiguration(AppcuesLaunchExperienceAction.Config(experienceID: "123")))
let failedAction = AppcuesLaunchExperienceAction()

// Assert
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppcuesKitTests/Actions/AppcuesLinkActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppcuesLinkActionTests: XCTestCase {

func testInit() throws {
// Act)
let action = AppcuesLinkAction(path: "https://appcues.com")
let action = AppcuesLinkAction(configuration: ExperiencePluginConfiguration(AppcuesLinkAction.Config(url: URL(string: "https://appcues.com")!, openExternally: nil)))
let failedAction = AppcuesLinkAction()

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AppcuesSubmitFormActionTests: XCTestCase {

func testInit() throws {
// Act
let action = AppcuesSubmitFormAction()
let action = AppcuesSubmitFormAction(configuration: ExperiencePluginConfiguration(nil))

// Assert
XCTAssertEqual(AppcuesSubmitFormAction.type, "@appcues/submit-form")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppcuesTrackActionTests: XCTestCase {
func testInit() throws {
// Act
let action = AppcuesTrackAction(eventName: "My Custom Event")
let failedAction = AppcuesTrackAction()
let failedAction = AppcuesTrackAction(configuration: ExperiencePluginConfiguration(nil))

// Assert
XCTAssertEqual(AppcuesTrackAction.type, "@appcues/track")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppcuesUpdateProfileActionTests: XCTestCase {
func testInit() throws {
// Act
let action = AppcuesUpdateProfileAction(properties: ["profile_attribute": "value"])
let failedAction = AppcuesUpdateProfileAction()
let failedAction = AppcuesUpdateProfileAction(configuration: ExperiencePluginConfiguration(nil))

// Assert
XCTAssertEqual(AppcuesUpdateProfileAction.type, "@appcues/update-profile")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ struct DecodableExpectation: Decodable {
let expectation: XCTestExpectation
private let expectationID: UUID

init(expectation: XCTestExpectation) {
init?(expectation: XCTestExpectation?) {
guard let expectation = expectation else { return nil }
self.expectation = expectation
self.expectationID = UUID()
Self.expectationStore[expectationID] = expectation
Expand Down
42 changes: 7 additions & 35 deletions Tests/AppcuesKitTests/Traits/TraitComposerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -473,31 +473,11 @@ extension TraitComposerTests {
wrapperCreatingExpectation: XCTestExpectation? = nil,
backdropDecoratingExpectation: XCTestExpectation?) {
self.groupID = groupID
if let stepDecoratingExpectation = stepDecoratingExpectation {
self.stepDecoratingExpectation = DecodableExpectation(expectation: stepDecoratingExpectation)
} else {
self.stepDecoratingExpectation = nil
}
if let containerCreatingExpectation = containerCreatingExpectation {
self.containerCreatingExpectation = DecodableExpectation(expectation: containerCreatingExpectation)
} else {
self.containerCreatingExpectation = nil
}
if let containerDecoratingExpectation = containerDecoratingExpectation {
self.containerDecoratingExpectation = DecodableExpectation(expectation: containerDecoratingExpectation)
} else {
self.containerDecoratingExpectation = nil
}
if let wrapperCreatingExpectation = wrapperCreatingExpectation {
self.wrapperCreatingExpectation = DecodableExpectation(expectation: wrapperCreatingExpectation)
} else {
self.wrapperCreatingExpectation = nil
}
if let backdropDecoratingExpectation = backdropDecoratingExpectation {
self.backdropDecoratingExpectation = DecodableExpectation(expectation: backdropDecoratingExpectation)
} else {
self.backdropDecoratingExpectation = nil
}
self.stepDecoratingExpectation = DecodableExpectation(expectation: stepDecoratingExpectation)
self.containerCreatingExpectation = DecodableExpectation(expectation: containerCreatingExpectation)
self.containerDecoratingExpectation = DecodableExpectation(expectation: containerDecoratingExpectation)
self.wrapperCreatingExpectation = DecodableExpectation(expectation: wrapperCreatingExpectation)
self.backdropDecoratingExpectation = DecodableExpectation(expectation: backdropDecoratingExpectation)
}
}
class var type: String { "@test/trait" }
Expand Down Expand Up @@ -580,16 +560,8 @@ extension TraitComposerTests {

init(groupID: String? = nil, presentExpectation: XCTestExpectation? = nil, removeExpectation: XCTestExpectation? = nil) {
self.groupID = groupID
if let presentExpectation = presentExpectation {
self.presentExpectation = DecodableExpectation(expectation: presentExpectation)
} else {
self.presentExpectation = nil
}
if let removeExpectation = removeExpectation {
self.removeExpectation = DecodableExpectation(expectation: removeExpectation)
} else {
self.removeExpectation = nil
}
self.presentExpectation = DecodableExpectation(expectation: presentExpectation)
self.removeExpectation = DecodableExpectation(expectation: removeExpectation)
}
}
static let type = "@test/presenting"
Expand Down

0 comments on commit 9931240

Please sign in to comment.