2018-11-02 18:02:53 +00:00
|
|
|
/* global Whisper */
|
|
|
|
|
2018-03-08 00:16:03 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
describe('Database', () => {
|
|
|
|
describe('handleDOMException', () => {
|
|
|
|
it('handles null, still calls reject', () => {
|
|
|
|
let called = 0;
|
|
|
|
const reject = () => {
|
2018-03-08 00:16:03 +00:00
|
|
|
called += 1;
|
|
|
|
};
|
2018-11-02 18:02:53 +00:00
|
|
|
const error = null;
|
|
|
|
const prefix = 'something';
|
2018-03-08 00:16:03 +00:00
|
|
|
|
|
|
|
Whisper.Database.handleDOMException(prefix, error, reject);
|
|
|
|
|
|
|
|
assert.strictEqual(called, 1);
|
|
|
|
});
|
|
|
|
|
2018-11-02 18:02:53 +00:00
|
|
|
it('handles object code and message', () => {
|
|
|
|
let called = 0;
|
|
|
|
const reject = () => {
|
2018-03-08 00:16:03 +00:00
|
|
|
called += 1;
|
|
|
|
};
|
2018-11-02 18:02:53 +00:00
|
|
|
const error = {
|
2018-03-08 00:16:03 +00:00
|
|
|
code: 4,
|
|
|
|
message: 'some cryptic error',
|
|
|
|
};
|
2018-11-02 18:02:53 +00:00
|
|
|
const prefix = 'something';
|
2018-03-08 00:16:03 +00:00
|
|
|
|
|
|
|
Whisper.Database.handleDOMException(prefix, error, reject);
|
|
|
|
|
|
|
|
assert.strictEqual(called, 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|