FIRDynamicLinkTest.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2021 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import <XCTest/XCTest.h>
  18. #import "FirebaseDynamicLinks/Sources/FIRDynamicLink+Private.h"
  19. @interface FIRDynamicLinkTest : XCTestCase {
  20. }
  21. @end
  22. @implementation FIRDynamicLinkTest
  23. NSMutableDictionary<NSString *, NSString *> *fdlParameters = nil;
  24. NSDictionary<NSString *, NSString *> *linkParameters = nil;
  25. NSDictionary<NSString *, NSString *> *utmParameters = nil;
  26. - (void)setUp {
  27. [super setUp];
  28. linkParameters = @{
  29. @"deep_link_id" : @"https://mmaksym.com/test-app1",
  30. @"match_message" : @"Link is uniquely matched for this device.",
  31. @"match_type" : @"unique",
  32. @"a_parameter" : @"a_value"
  33. };
  34. utmParameters = @{
  35. @"utm_campaign" : @"eldhosembabu Test",
  36. @"utm_medium" : @"test_medium",
  37. @"utm_source" : @"test_source",
  38. };
  39. fdlParameters = [[NSMutableDictionary alloc] initWithDictionary:linkParameters];
  40. [fdlParameters addEntriesFromDictionary:utmParameters];
  41. }
  42. - (void)testDynamicLinkParameters_InitWithParameters {
  43. FIRDynamicLink *dynamicLink = [[FIRDynamicLink alloc] initWithParametersDictionary:fdlParameters];
  44. XCTAssertEqual([fdlParameters count], [[dynamicLink parametersDictionary] count]);
  45. for (NSString *key in fdlParameters) {
  46. NSString *expectedValue = [fdlParameters valueForKey:key];
  47. NSString *derivedValue = [[dynamicLink parametersDictionary] valueForKey:key];
  48. XCTAssertNotNil(derivedValue, @"Cannot be null!");
  49. XCTAssertEqualObjects(derivedValue, expectedValue);
  50. }
  51. }
  52. - (void)testDynamicLinkUtmParameters_InitWithParameters {
  53. FIRDynamicLink *dynamicLink = [[FIRDynamicLink alloc] initWithParametersDictionary:fdlParameters];
  54. XCTAssertEqual([[dynamicLink utmParametersDictionary] count], [utmParameters count]);
  55. for (NSString *key in utmParameters) {
  56. NSString *expectedValue = [utmParameters valueForKey:key];
  57. NSString *derivedValue = [[dynamicLink utmParametersDictionary] valueForKey:key];
  58. XCTAssertNotNil(derivedValue, @"Cannot be null!");
  59. XCTAssertEqualObjects(derivedValue, expectedValue);
  60. }
  61. }
  62. - (void)testDynamicLinkParameters_InitWithNoUtmParameters {
  63. FIRDynamicLink *dynamicLink =
  64. [[FIRDynamicLink alloc] initWithParametersDictionary:linkParameters];
  65. XCTAssertEqual([[dynamicLink parametersDictionary] count], [linkParameters count]);
  66. XCTAssertEqual([[dynamicLink utmParametersDictionary] count], 0);
  67. }
  68. @end