33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import { module, test } from 'qunit';
|
|
import { getIdentityApi, canUseExtensionAuth } from 'dashtab/utils/extension';
|
|
|
|
module('Unit | Utility | extension', function () {
|
|
test('returns null without an identity API', function (assert) {
|
|
assert.strictEqual(getIdentityApi(null), null);
|
|
assert.strictEqual(getIdentityApi({}), null);
|
|
});
|
|
|
|
test('returns the identity API when both functions exist', function (assert) {
|
|
const identity = { launchWebAuthFlow() {}, getRedirectURL() {} };
|
|
|
|
assert.strictEqual(getIdentityApi({ identity }), identity);
|
|
});
|
|
|
|
test('ignores a partial identity API', function (assert) {
|
|
assert.strictEqual(
|
|
getIdentityApi({ identity: { launchWebAuthFlow() {} } }),
|
|
null
|
|
);
|
|
assert.strictEqual(
|
|
getIdentityApi({ identity: { getRedirectURL() {} } }),
|
|
null
|
|
);
|
|
});
|
|
|
|
test('canUseExtensionAuth is false without an identity API', function (assert) {
|
|
// Test runs in a normal page context, where `chrome` (if present) has no
|
|
// identity API.
|
|
assert.false(canUseExtensionAuth());
|
|
});
|
|
});
|