Skip to content

Commit cbaa03c

Browse files
author
Christopher J. Brody
committed
test logging with custom prefix 'ABC' using mocks
1 parent 511313a commit cbaa03c

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Array [
88
99
root moduleName: react-native-alice-bobbi
1010
name: alice-bobbi
11-
prefix:
11+
prefix: ABC
1212
modulePrefix: react-native
1313
packageIdentifier: com.alicebits
1414
platforms: android,ios
@@ -107,10 +107,10 @@ Array [
107107
"ensureDir": "react-native-alice-bobbi/ios/",
108108
},
109109
Object {
110-
"ensureDir": "react-native-alice-bobbi/ios/AliceBobbi.xcworkspace/",
110+
"ensureDir": "react-native-alice-bobbi/ios/ABCAliceBobbi.xcworkspace/",
111111
},
112112
Object {
113-
"ensureDir": "react-native-alice-bobbi/ios/AliceBobbi.xcodeproj/",
113+
"ensureDir": "react-native-alice-bobbi/ios/ABCAliceBobbi.xcodeproj/",
114114
},
115115
Object {
116116
"outputFileName": "react-native-alice-bobbi/README.md",
@@ -130,15 +130,15 @@ Array [
130130
#### iOS
131131
132132
1. In XCode, in the project navigator, right click \`Libraries\`\`Add Files to [your project's name]\`
133-
2. Go to \`node_modules\`\`react-native-alice-bobbi\` and add \`AliceBobbi.xcodeproj\`
134-
3. In XCode, in the project navigator, select your project. Add \`libAliceBobbi.a\` to your project's \`Build Phases\`\`Link Binary With Libraries\`
133+
2. Go to \`node_modules\`\`react-native-alice-bobbi\` and add \`ABCAliceBobbi.xcodeproj\`
134+
3. In XCode, in the project navigator, select your project. Add \`libABCAliceBobbi.a\` to your project's \`Build Phases\`\`Link Binary With Libraries\`
135135
4. Run your project (\`Cmd+R\`)<
136136
137137
#### Android
138138
139139
1. Open up \`android/app/src/main/java/[...]/MainApplication.java\`
140-
- Add \`import com.alicebits.AliceBobbiPackage;\` to the imports at the top of the file
141-
- Add \`new AliceBobbiPackage()\` to the list returned by the \`getPackages()\` method
140+
- Add \`import com.alicebits.ABCAliceBobbiPackage;\` to the imports at the top of the file
141+
- Add \`new ABCAliceBobbiPackage()\` to the list returned by the \`getPackages()\` method
142142
2. Append the following lines to \`android/settings.gradle\`:
143143
\`\`\`
144144
include ':react-native-alice-bobbi'
@@ -152,10 +152,10 @@ Array [
152152
153153
## Usage
154154
\`\`\`javascript
155-
import AliceBobbi from 'react-native-alice-bobbi';
155+
import ABCAliceBobbi from 'react-native-alice-bobbi';
156156
157157
// TODO: What to do with the module?
158-
AliceBobbi;
158+
ABCAliceBobbi;
159159
\`\`\`
160160
",
161161
},
@@ -200,9 +200,9 @@ AliceBobbi;
200200
"outputFileName": "react-native-alice-bobbi/index.js",
201201
"theContent": "import { NativeModules } from 'react-native';
202202
203-
const { AliceBobbi } = NativeModules;
203+
const { ABCAliceBobbi } = NativeModules;
204204
205-
export default AliceBobbi;
205+
export default ABCAliceBobbi;
206206
",
207207
},
208208
Object {
@@ -401,26 +401,26 @@ afterEvaluate { project ->
401401
",
402402
},
403403
Object {
404-
"outputFileName": "react-native-alice-bobbi/android/src/main/java/com/alicebits/AliceBobbiModule.java",
404+
"outputFileName": "react-native-alice-bobbi/android/src/main/java/com/alicebits/ABCAliceBobbiModule.java",
405405
"theContent": "package com.alicebits;
406406
407407
import com.facebook.react.bridge.ReactApplicationContext;
408408
import com.facebook.react.bridge.ReactContextBaseJavaModule;
409409
import com.facebook.react.bridge.ReactMethod;
410410
import com.facebook.react.bridge.Callback;
411411
412-
public class AliceBobbiModule extends ReactContextBaseJavaModule {
412+
public class ABCAliceBobbiModule extends ReactContextBaseJavaModule {
413413
414414
private final ReactApplicationContext reactContext;
415415
416-
public AliceBobbiModule(ReactApplicationContext reactContext) {
416+
public ABCAliceBobbiModule(ReactApplicationContext reactContext) {
417417
super(reactContext);
418418
this.reactContext = reactContext;
419419
}
420420
421421
@Override
422422
public String getName() {
423-
return \\"AliceBobbi\\";
423+
return \\"ABCAliceBobbi\\";
424424
}
425425
426426
@ReactMethod
@@ -432,7 +432,7 @@ public class AliceBobbiModule extends ReactContextBaseJavaModule {
432432
",
433433
},
434434
Object {
435-
"outputFileName": "react-native-alice-bobbi/android/src/main/java/com/alicebits/AliceBobbiPackage.java",
435+
"outputFileName": "react-native-alice-bobbi/android/src/main/java/com/alicebits/ABCAliceBobbiPackage.java",
436436
"theContent": "package com.alicebits;
437437
438438
import java.util.Arrays;
@@ -445,10 +445,10 @@ import com.facebook.react.bridge.ReactApplicationContext;
445445
import com.facebook.react.uimanager.ViewManager;
446446
import com.facebook.react.bridge.JavaScriptModule;
447447
448-
public class AliceBobbiPackage implements ReactPackage {
448+
public class ABCAliceBobbiPackage implements ReactPackage {
449449
@Override
450450
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
451-
return Arrays.<NativeModule>asList(new AliceBobbiModule(reactContext));
451+
return Arrays.<NativeModule>asList(new ABCAliceBobbiModule(reactContext));
452452
}
453453
454454
@Override
@@ -507,20 +507,20 @@ end
507507
",
508508
},
509509
Object {
510-
"outputFileName": "react-native-alice-bobbi/ios/AliceBobbi.h",
510+
"outputFileName": "react-native-alice-bobbi/ios/ABCAliceBobbi.h",
511511
"theContent": "#import <React/RCTBridgeModule.h>
512512
513-
@interface AliceBobbi : NSObject <RCTBridgeModule>
513+
@interface ABCAliceBobbi : NSObject <RCTBridgeModule>
514514
515515
@end
516516
",
517517
},
518518
Object {
519-
"outputFileName": "react-native-alice-bobbi/ios/AliceBobbi.m",
520-
"theContent": "#import \\"AliceBobbi.h\\"
519+
"outputFileName": "react-native-alice-bobbi/ios/ABCAliceBobbi.m",
520+
"theContent": "#import \\"ABCAliceBobbi.h\\"
521521
522522
523-
@implementation AliceBobbi
523+
@implementation ABCAliceBobbi
524524
525525
RCT_EXPORT_MODULE()
526526
@@ -534,18 +534,18 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
534534
",
535535
},
536536
Object {
537-
"outputFileName": "react-native-alice-bobbi/ios/AliceBobbi.xcworkspace/contents.xcworkspacedata",
537+
"outputFileName": "react-native-alice-bobbi/ios/ABCAliceBobbi.xcworkspace/contents.xcworkspacedata",
538538
"theContent": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
539539
<Workspace
540540
version = \\"1.0\\">
541541
<FileRef
542-
location = \\"group:AliceBobbi.xcodeproj\\">
542+
location = \\"group:ABCAliceBobbi.xcodeproj\\">
543543
</FileRef>
544544
</Workspace>
545545
",
546546
},
547547
Object {
548-
"outputFileName": "react-native-alice-bobbi/ios/AliceBobbi.xcodeproj/project.pbxproj",
548+
"outputFileName": "react-native-alice-bobbi/ios/ABCAliceBobbi.xcodeproj/project.pbxproj",
549549
"theContent": "// !$*UTF8*$!
550550
{
551551
archiveVersion = 1;
@@ -555,7 +555,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
555555
objects = {
556556
557557
/* Begin PBXBuildFile section */
558-
B3E7B58A1CC2AC0600A0062D /* AliceBobbi.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AliceBobbi.m */; };
558+
B3E7B58A1CC2AC0600A0062D /* ABCAliceBobbi.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* ABCAliceBobbi.m */; };
559559
/* End PBXBuildFile section */
560560
561561
/* Begin PBXCopyFilesBuildPhase section */
@@ -571,9 +571,9 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
571571
/* End PBXCopyFilesBuildPhase section */
572572
573573
/* Begin PBXFileReference section */
574-
134814201AA4EA6300B7C361 /* libAliceBobbi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAliceBobbi.a; sourceTree = BUILT_PRODUCTS_DIR; };
575-
B3E7B5881CC2AC0600A0062D /* AliceBobbi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliceBobbi.h; sourceTree = \\"<group>\\"; };
576-
B3E7B5891CC2AC0600A0062D /* AliceBobbi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliceBobbi.m; sourceTree = \\"<group>\\"; };
574+
134814201AA4EA6300B7C361 /* libABCAliceBobbi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libABCAliceBobbi.a; sourceTree = BUILT_PRODUCTS_DIR; };
575+
B3E7B5881CC2AC0600A0062D /* ABCAliceBobbi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ABCAliceBobbi.h; sourceTree = \\"<group>\\"; };
576+
B3E7B5891CC2AC0600A0062D /* ABCAliceBobbi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ABCAliceBobbi.m; sourceTree = \\"<group>\\"; };
577577
/* End PBXFileReference section */
578578
579579
/* Begin PBXFrameworksBuildPhase section */
@@ -590,26 +590,26 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
590590
134814211AA4EA7D00B7C361 /* Products */ = {
591591
isa = PBXGroup;
592592
children = (
593-
134814201AA4EA6300B7C361 /* libAliceBobbi.a */,
593+
134814201AA4EA6300B7C361 /* libABCAliceBobbi.a */,
594594
);
595595
name = Products;
596596
sourceTree = \\"<group>\\";
597597
};
598598
58B511D21A9E6C8500147676 = {
599599
isa = PBXGroup;
600600
children = (
601-
B3E7B5881CC2AC0600A0062D /* AliceBobbi.h */,
602-
B3E7B5891CC2AC0600A0062D /* AliceBobbi.m */,
601+
B3E7B5881CC2AC0600A0062D /* ABCAliceBobbi.h */,
602+
B3E7B5891CC2AC0600A0062D /* ABCAliceBobbi.m */,
603603
134814211AA4EA7D00B7C361 /* Products */,
604604
);
605605
sourceTree = \\"<group>\\";
606606
};
607607
/* End PBXGroup section */
608608
609609
/* Begin PBXNativeTarget section */
610-
58B511DA1A9E6C8500147676 /* AliceBobbi */ = {
610+
58B511DA1A9E6C8500147676 /* ABCAliceBobbi */ = {
611611
isa = PBXNativeTarget;
612-
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"AliceBobbi\\" */;
612+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"ABCAliceBobbi\\" */;
613613
buildPhases = (
614614
58B511D71A9E6C8500147676 /* Sources */,
615615
58B511D81A9E6C8500147676 /* Frameworks */,
@@ -619,9 +619,9 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
619619
);
620620
dependencies = (
621621
);
622-
name = AliceBobbi;
622+
name = ABCAliceBobbi;
623623
productName = RCTDataManager;
624-
productReference = 134814201AA4EA6300B7C361 /* libAliceBobbi.a */;
624+
productReference = 134814201AA4EA6300B7C361 /* libABCAliceBobbi.a */;
625625
productType = \\"com.apple.product-type.library.static\\";
626626
};
627627
/* End PBXNativeTarget section */
@@ -638,7 +638,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
638638
};
639639
};
640640
};
641-
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject \\"AliceBobbi\\" */;
641+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject \\"ABCAliceBobbi\\" */;
642642
compatibilityVersion = \\"Xcode 3.2\\";
643643
developmentRegion = English;
644644
hasScannedForEncodings = 0;
@@ -650,7 +650,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
650650
projectDirPath = \\"\\";
651651
projectRoot = \\"\\";
652652
targets = (
653-
58B511DA1A9E6C8500147676 /* AliceBobbi */,
653+
58B511DA1A9E6C8500147676 /* ABCAliceBobbi */,
654654
);
655655
};
656656
/* End PBXProject section */
@@ -660,7 +660,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
660660
isa = PBXSourcesBuildPhase;
661661
buildActionMask = 2147483647;
662662
files = (
663-
B3E7B58A1CC2AC0600A0062D /* AliceBobbi.m in Sources */,
663+
B3E7B58A1CC2AC0600A0062D /* ABCAliceBobbi.m in Sources */,
664664
);
665665
runOnlyForDeploymentPostprocessing = 0;
666666
};
@@ -771,7 +771,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
771771
);
772772
LIBRARY_SEARCH_PATHS = \\"$(inherited)\\";
773773
OTHER_LDFLAGS = \\"-ObjC\\";
774-
PRODUCT_NAME = AliceBobbi;
774+
PRODUCT_NAME = ABCAliceBobbi;
775775
SKIP_INSTALL = YES;
776776
};
777777
name = Debug;
@@ -787,15 +787,15 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
787787
);
788788
LIBRARY_SEARCH_PATHS = \\"$(inherited)\\";
789789
OTHER_LDFLAGS = \\"-ObjC\\";
790-
PRODUCT_NAME = AliceBobbi;
790+
PRODUCT_NAME = ABCAliceBobbi;
791791
SKIP_INSTALL = YES;
792792
};
793793
name = Release;
794794
};
795795
/* End XCBuildConfiguration section */
796796
797797
/* Begin XCConfigurationList section */
798-
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject \\"AliceBobbi\\" */ = {
798+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject \\"ABCAliceBobbi\\" */ = {
799799
isa = XCConfigurationList;
800800
buildConfigurations = (
801801
58B511ED1A9E6C8500147676 /* Debug */,
@@ -804,7 +804,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
804804
defaultConfigurationIsVisible = 0;
805805
defaultConfigurationName = Release;
806806
};
807-
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"AliceBobbi\\" */ = {
807+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget \\"ABCAliceBobbi\\" */ = {
808808
isa = XCConfigurationList;
809809
buildConfigurations = (
810810
58B511F01A9E6C8500147676 /* Debug */,
@@ -966,15 +966,15 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
966966
967967
import React, { Component } from 'react';
968968
import { Platform, StyleSheet, Text, View } from 'react-native';
969-
import AliceBobbi from 'react-native-alice-bobbi';
969+
import ABCAliceBobbi from 'react-native-alice-bobbi';
970970
971971
export default class App extends Component<{}> {
972972
state = {
973973
status: 'starting',
974974
message: '--'
975975
};
976976
componentDidMount() {
977-
AliceBobbi.sampleMethod('Testing', 123, (message) => {
977+
ABCAliceBobbi.sampleMethod('Testing', 123, (message) => {
978978
this.setState({
979979
status: 'native callback received',
980980
message
@@ -984,7 +984,7 @@ export default class App extends Component<{}> {
984984
render() {
985985
return (
986986
<View style={styles.container}>
987-
<Text style={styles.welcome}>☆AliceBobbi example☆</Text>
987+
<Text style={styles.welcome}>☆ABCAliceBobbi example☆</Text>
988988
<Text style={styles.instructions}>STATUS: {this.state.status}</Text>
989989
<Text style={styles.welcome}>☆NATIVE CALLBACK MESSAGE☆</Text>
990990
<Text style={styles.instructions}>{this.state.message}</Text>

tests/with-mocks/lib/create/with-example/with-logging/with-options/create-with-example-with-options.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ test('create alice-bobbi module using mocked lib with logging, with example, for
4343
const options = {
4444
platforms: ['android', 'ios'],
4545
name: 'alice-bobbi',
46+
prefix: 'ABC',
4647
packageIdentifier: 'com.alicebits',
4748
githubAccount: 'alicebits',
4849
authorName: 'Alice',

0 commit comments

Comments
 (0)