[crash][both] Add support for isCrashCollectionEnabled & setCrashCollectionEnabled

This commit is contained in:
Elliot Hesp 2017-06-12 14:26:56 +01:00
parent 400a0ffbe0
commit 4c87131328
3 changed files with 47 additions and 1 deletions

View File

@ -19,6 +19,15 @@ RCT_EXPORT_METHOD(report:(NSString *) message) {
assert(NO);
}
RCT_EXPORT_METHOD(setCrashCollectionEnabled:(BOOL *) enabled) {
// Not available yet
}
RCT_EXPORT_METHOD(isCrashCollectionEnabled:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
// Not available yet
resolve(@YES);
}
@end
#else

View File

@ -11,6 +11,22 @@ export default class Crash {
}
}
/**
* Enables/Disables crash reporting
* @param enabled
*/
setCrashCollectionEnabled(enabled: boolean): void {
FirebaseCrash.setCrashCollectionEnabled(enabled);
}
/**
* Returns whether or not crash reporting is currently enabled
* @returns {Promise.<boolean>}
*/
isCrashCollectionEnabled(): Promise<boolean> {
return FirebaseCrash.isCrashCollectionEnabled();
}
/**
* Logs a message that will appear in a subsequent crash report.
* @param {string} message

View File

@ -1,4 +1,25 @@
export default function addTests({ describe, it, firebase }) {
export default function addTests({ describe, fdescribe, it, firebase }) {
fdescribe('API', () => {
it('it should set collection enabled/disabled', () => {
return new Promise((resolve) => {
firebase.native.crash().setCrashCollectionEnabled(false);
firebase.native.crash().setCrashCollectionEnabled(true);
resolve();
});
});
it('it should return whether crash reporting is enabled', () => {
return new Promise((resolve) => {
firebase.native.crash().isCrashCollectionEnabled()
.then((enabled) => {
enabled.should.be.a.Boolean();
resolve();
});
});
});
});
describe('Log', () => {
it('log: it should log without error', () => {
return new Promise((resolve) => {