-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting Profile in separate components for AX snapshot testing
A `SnapshotTest` native module was created to register every component from the JavaScript thread instead of having to modify Swift files every time
- Loading branch information
1 parent
c994a7d
commit d9f7b7c
Showing
10 changed files
with
153 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
import XCTest | ||
import React | ||
|
||
@objc(SnapshotTests) | ||
class SnapshotTests: NSObject, RCTBridgeModule { | ||
static func moduleName() -> String! { | ||
"SnapshotTests" | ||
} | ||
|
||
var items: [String]? = [] | ||
|
||
@objc(registerName:) | ||
func register(name: String) -> NSNumber? { | ||
guard let items = items else { | ||
return nil | ||
} | ||
|
||
if items.contains(name) { | ||
self.items = nil | ||
NSException.raise(.init(rawValue: "Name already registered"), | ||
format: "%@ already registered", | ||
arguments: getVaList([name])) | ||
print("\(name) already registered") | ||
} | ||
|
||
self.items!.append(name) | ||
return NSNumber(booleanLiteral: true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RCT_EXTERN_MODULE(SnapshotTests, NSObject) | ||
|
||
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(registerName:(NSString *)name) | ||
|
||
@end |
Binary file added
BIN
+74.9 KB
...s/__Snapshots__/AccessibilitySnapshotTests/accessibility.ProfileButtonsTest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+66.8 KB
...s/__Snapshots__/AccessibilitySnapshotTests/accessibility.ProfilePictureTest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.5 KB
...sts/__Snapshots__/AccessibilitySnapshotTests/accessibility.ProfileStatsTest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {AppRegistry, NativeModules} from 'react-native'; | ||
|
||
export default function registerAccessibilitySnapshotNode( | ||
name: string, | ||
node: JSX.Element, | ||
) { | ||
AppRegistry.registerComponent(name, () => () => node); | ||
const {SnapshotTests} = NativeModules; | ||
if (!SnapshotTests) { | ||
return; | ||
} | ||
|
||
const result = SnapshotTests.registerName(name); | ||
if (!result) { | ||
throw new Error(`Couldn't register ${name}`); | ||
} | ||
} |