fix(sqlite): fix callback issue with transaction method

closes #732
This commit is contained in:
Ibby
2016-10-27 07:59:33 -04:00
committed by Ibrahim Hadeed
parent 6f4737190b
commit a72cd59b99
2 changed files with 55 additions and 10 deletions
+32
View File
@@ -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();
});
});