fix: adjust test cases
This commit is contained in:
parent
b6c3b0d319
commit
e190066be6
@ -84,7 +84,9 @@ describe('NfcManager (ios)', () => {
|
||||
NfcManager.setEventListener(NfcEvents.SessionClosed, () => {
|
||||
sessionClosed = true;
|
||||
});
|
||||
NfcManagerEmitter._testTriggerCallback(NfcEvents.SessionClosed);
|
||||
NfcManagerEmitter._testTriggerCallback(NfcEvents.SessionClosed, {
|
||||
error: 'NFCError:200',
|
||||
});
|
||||
expect(sessionClosed).toBe(true);
|
||||
});
|
||||
|
||||
@ -107,7 +109,7 @@ describe('NfcManager (ios)', () => {
|
||||
// default can be overriden by throwOnError
|
||||
await NfcManager.cancelTechnologyRequest({throwOnError: true});
|
||||
} catch (ex) {
|
||||
expect(ex).toEqual('fake-error-again');
|
||||
expect(ex.message).toEqual('fake-error-again');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
let _nextError = null;
|
||||
let _nextErrorMethod = null;
|
||||
|
||||
const NativeNfcManager = {
|
||||
MIFARE_BLOCK_SIZE: 16,
|
||||
MIFARE_ULTRALIGHT_PAGE_SIZE: 4,
|
||||
setNextError: (err) => {
|
||||
setNextError: (err, nativeMethodName = null) => {
|
||||
_nextError = err;
|
||||
_nextErrorMethod = nativeMethodName;
|
||||
},
|
||||
};
|
||||
|
||||
@ -20,9 +22,11 @@ const NfcManagerEmitter = {
|
||||
};
|
||||
|
||||
const callNative = jest.fn((...args) => {
|
||||
if (_nextError) {
|
||||
const [methodName, ...rest] = args;
|
||||
if (_nextError && (!methodName || methodName === _nextErrorMethod)) {
|
||||
const err = _nextError;
|
||||
_nextError = null;
|
||||
_nextErrorMethod = null;
|
||||
return Promise.reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user