func testAttributeCpasEvent()

in FBAEMKit/FBAEMKitTests/AEMInvocationTests.swift [668:719]


  func testAttributeCpasEvent() {
    let invocation = _AEMInvocation(
      campaignID: "test_campaign_1234",
      acsToken: "test_token_12345",
      acsSharedSecret: nil,
      acsConfigID: nil,
      businessID: "test_advertiserid_cpas",
      catalogID: nil,
      isTestMode: false,
      hasSKAN: false,
      isConversionFilteringEligible: true
    )! // swiftlint:disable:this force_unwrapping
    let configs = [
      Values.defaultMode: [SampleAEMConfigurations.createConfigWithoutBusinessID()],
      Values.cpasMode: [SampleAEMConfigurations.createCpasConfig()],
    ]
    let isAttributed = invocation.attributeEvent(
      Values.purchase,
      currency: Values.USD,
      value: NSNumber(value: 5000),
      parameters: [
        Keys.content: [
          [
            Keys.identity: "abc",
            Keys.itemPrice: NSNumber(value: 100),
            Keys.quantity: NSNumber(value: 10),
          ],
          [
            Keys.identity: "test",
            Keys.itemPrice: NSNumber(value: 200),
            Keys.quantity: NSNumber(value: 20),
          ],
        ],
      ],
      configs: configs,
      shouldUpdateCache: true
    )
    XCTAssertTrue(
      isAttributed,
      "Should attribute the event"
    )
    XCTAssertEqual(
      invocation.recordedEvents,
      [Values.purchase],
      "Should expect the event is updated in the cache"
    )
    XCTAssertEqual(
      invocation.recordedValues,
      [Values.purchase: [Values.USD: 1000]],
      "Should expect the value is updated in the cache"
    )
  }