-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup-link.ts
26 lines (21 loc) · 940 Bytes
/
setup-link.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { assert } from '@ember/debug';
import TestInstrumentedLinkManagerService from './-services/test-instrumented-link-manager';
import type { TestContext } from '@ember/test-helpers';
interface Hooks {
beforeEach(callback: () => void): void;
}
export default function setupLink(hooks: Hooks /* NestedHooks */) {
hooks.beforeEach(function (this: TestContext) {
assert(
'ember-link.setupLink: You have already called `setupLink` once',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
!this.owner.hasRegistration('service:link-manager') ||
!(this.owner.lookup('service:link-manager') instanceof TestInstrumentedLinkManagerService)
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.owner.unregister('service:link-manager');
this.owner.register('service:link-manager', TestInstrumentedLinkManagerService);
});
}