XCUIElementHelpersTests.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <XCTest/XCTest.h>
  10. #import "FBElementUtils.h"
  11. @interface XCUIElementHelpersTests : XCTestCase
  12. @property (nonatomic) NSDictionary *namesMapping;
  13. @end
  14. @implementation XCUIElementHelpersTests
  15. - (void)setUp
  16. {
  17. [super setUp];
  18. self.namesMapping = [FBElementUtils wdAttributeNamesMapping];
  19. }
  20. - (void)testMappingContainsNamesAndAliases
  21. {
  22. XCTAssertTrue([self.namesMapping.allKeys containsObject:@"wdName"]);
  23. XCTAssertTrue([self.namesMapping.allKeys containsObject:@"name"]);
  24. }
  25. - (void)testMappingContainsCorrectValueForAttrbutesWithoutGetters
  26. {
  27. XCTAssertTrue([[self.namesMapping objectForKey:@"label"] isEqualToString:@"wdLabel"]);
  28. XCTAssertTrue([[self.namesMapping objectForKey:@"wdLabel"] isEqualToString:@"wdLabel"]);
  29. }
  30. - (void)testMappingContainsCorrectValueForAttrbutesWithGetters
  31. {
  32. XCTAssertTrue([[self.namesMapping objectForKey:@"visible"] isEqualToString:@"isWDVisible"]);
  33. XCTAssertTrue([[self.namesMapping objectForKey:@"wdVisible"] isEqualToString:@"isWDVisible"]);
  34. }
  35. - (void)testEachPropertyHasAlias
  36. {
  37. NSArray *aliases = [self.namesMapping.allKeys filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT(SELF beginsWith[c] 'wd')"]];
  38. NSArray *names = [self.namesMapping.allKeys filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginsWith[c] 'wd'"]];
  39. XCTAssertEqual(aliases.count, names.count);
  40. }
  41. @end