From ef33c01dcccb5dd321ade88db859eae033a5dd7d Mon Sep 17 00:00:00 2001 From: bobrimperator Date: Fri, 27 Dec 2024 05:10:49 +0100 Subject: [PATCH 1/3] feat(ember-simple-auth): remove inject util. This util is useless now since the APIs for registry and the container have stabilised. --- packages/ember-simple-auth/src/utils/inject.js | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 packages/ember-simple-auth/src/utils/inject.js diff --git a/packages/ember-simple-auth/src/utils/inject.js b/packages/ember-simple-auth/src/utils/inject.js deleted file mode 100644 index cc01eed38..000000000 --- a/packages/ember-simple-auth/src/utils/inject.js +++ /dev/null @@ -1,4 +0,0 @@ -export default function (registry, factoryNameOrType, property, injectionName) { - const inject = registry.inject || registry.injection; - inject.call(registry, factoryNameOrType, property, injectionName); -} From 2bd1419840306fb50a790c02207e8d4857d87ed7 Mon Sep 17 00:00:00 2001 From: bobrimperator Date: Fri, 27 Dec 2024 05:16:55 +0100 Subject: [PATCH 2/3] test(test-esa): remove assign-test.js --- packages/test-esa/tests/unit/utils/assign-test.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 packages/test-esa/tests/unit/utils/assign-test.js diff --git a/packages/test-esa/tests/unit/utils/assign-test.js b/packages/test-esa/tests/unit/utils/assign-test.js deleted file mode 100644 index c318ec5cb..000000000 --- a/packages/test-esa/tests/unit/utils/assign-test.js +++ /dev/null @@ -1,9 +0,0 @@ -import { module, test } from 'qunit'; - -module('Unit | Utility | assign', function () { - test('it works', function (assert) { - let result = Object.assign({ foo: 'foo' }, { bar: 'bar' }); - - assert.deepEqual(result, { foo: 'foo', bar: 'bar' }); - }); -}); From 2114200f4928f93825f7968b7e61dc32c7af5c31 Mon Sep 17 00:00:00 2001 From: bobrimperator Date: Fri, 27 Dec 2024 05:26:48 +0100 Subject: [PATCH 3/3] feat(typescript): migrate test-support --- .../src/test-support/{index.js => index.ts} | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) rename packages/ember-simple-auth/src/test-support/{index.js => index.ts} (67%) diff --git a/packages/ember-simple-auth/src/test-support/index.js b/packages/ember-simple-auth/src/test-support/index.ts similarity index 67% rename from packages/ember-simple-auth/src/test-support/index.js rename to packages/ember-simple-auth/src/test-support/index.ts index 87ea1eadc..49dbb4ec4 100644 --- a/packages/ember-simple-auth/src/test-support/index.js +++ b/packages/ember-simple-auth/src/test-support/index.ts @@ -5,7 +5,7 @@ import Test from '../authenticators/test'; const SESSION_SERVICE_KEY = 'service:session'; const TEST_CONTAINER_KEY = 'authenticator:test'; -function ensureAuthenticator(owner) { +function ensureAuthenticator(owner: any) { const authenticator = owner.lookup(TEST_CONTAINER_KEY); if (!authenticator) { owner.register(TEST_CONTAINER_KEY, Test); @@ -20,13 +20,13 @@ function ensureAuthenticator(owner) { * @return {Promise} * @public */ -export function authenticateSession(sessionData) { - const { owner } = getContext(); +export async function authenticateSession(sessionData: Record) { + const { owner } = getContext() as { owner: any }; const session = owner.lookup(SESSION_SERVICE_KEY); ensureAuthenticator(owner); - return session.authenticate(TEST_CONTAINER_KEY, sessionData).then(() => { - return settled(); - }); + + await session.authenticate(TEST_CONTAINER_KEY, sessionData); + await settled(); } /** @@ -36,7 +36,7 @@ export function authenticateSession(sessionData) { * @public */ export function currentSession() { - const { owner } = getContext(); + const { owner } = getContext() as { owner: any }; return owner.lookup(SESSION_SERVICE_KEY); } @@ -46,15 +46,14 @@ export function currentSession() { * @return {Promise} * @public */ -export function invalidateSession() { - const { owner } = getContext(); +export async function invalidateSession() { + const { owner } = getContext() as { owner: any }; const session = owner.lookup(SESSION_SERVICE_KEY); const isAuthenticated = get(session, 'isAuthenticated'); - return Promise.resolve() - .then(() => { - if (isAuthenticated) { - return session.invalidate(); - } - }) - .then(() => settled()); + + if (isAuthenticated) { + return session.invalidate(); + } + + await settled(); }