Files
marco/tests/unit/routes/oauth/osm-callback-test.js
Râu Cao e7dfed204e
All checks were successful
CI / Lint (pull_request) Successful in 30s
CI / Test (pull_request) Successful in 49s
Release Drafter / Update release notes draft (pull_request) Successful in 4s
Connect OSM account
2026-04-01 18:46:19 +04:00

48 lines
1.2 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'marco/tests/helpers';
import Service from '@ember/service';
class MockOsmAuthService extends Service {
handleCallbackCalled = false;
async handleCallback() {
this.handleCallbackCalled = true;
return Promise.resolve();
}
}
class MockRouterService extends Service {
transitionToArgs = [];
transitionTo(...args) {
this.transitionToArgs.push(args);
}
}
module('Unit | Route | oauth/osm-callback', function (hooks) {
setupTest(hooks);
hooks.beforeEach(function () {
this.owner.register('service:osmAuth', MockOsmAuthService);
this.owner.register('service:router', MockRouterService);
});
test('it handles the callback and transitions to index', async function (assert) {
let route = this.owner.lookup('route:oauth/osm-callback');
let osmAuth = this.owner.lookup('service:osmAuth');
let router = this.owner.lookup('service:router');
await route.model();
assert.true(
osmAuth.handleCallbackCalled,
'handleCallback was called on the osmAuth service'
);
assert.deepEqual(
router.transitionToArgs,
[['index']],
'router transitioned back to index route'
);
});
});