signal-desktop/test/database_test.js

40 lines
876 B
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2018-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-02 18:02:53 +00:00
/* global Whisper */
'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 = () => {
called += 1;
};
2018-11-02 18:02:53 +00:00
const error = null;
const prefix = 'something';
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 = () => {
called += 1;
};
2018-11-02 18:02:53 +00:00
const error = {
code: 4,
message: 'some cryptic error',
};
2018-11-02 18:02:53 +00:00
const prefix = 'something';
Whisper.Database.handleDOMException(prefix, error, reject);
assert.strictEqual(called, 1);
});
});
});