mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-02 00:07:23 +08:00
@@ -138,4 +138,36 @@ describe('plugin', () => {
|
||||
|
||||
});
|
||||
|
||||
it('reverse callback at the end of the function', done => {
|
||||
|
||||
window.plugins.test.reverseEndCallback = (args, error, success) => {
|
||||
success('Success');
|
||||
};
|
||||
|
||||
@Plugin(testPluginMeta)
|
||||
class Test {
|
||||
|
||||
@Cordova({
|
||||
successIndex: 2,
|
||||
errorIndex: 1
|
||||
})
|
||||
static reverseEndCallback(args: any): Promise<any> { return; }
|
||||
|
||||
}
|
||||
|
||||
const spy = spyOn(window.plugins.test, 'reverseEndCallback').and.callThrough();
|
||||
const cb = (result) => {
|
||||
expect(result).toEqual('Success');
|
||||
done();
|
||||
};
|
||||
|
||||
Test.reverseEndCallback('foo').then(cb, cb);
|
||||
|
||||
expect(spy.calls.mostRecent().args[0]).toEqual('foo');
|
||||
expect(spy.calls.mostRecent().args[1]).toBeDefined();
|
||||
expect(spy.calls.mostRecent().args[2]).toBeDefined();
|
||||
expect(spy.calls.mostRecent().args[3]).toBeUndefined();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user