Skip to content

Commit b1b9545

Browse files
committed
ope
1 parent f296275 commit b1b9545

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

test-app/tests/core/raw-api-test.gts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
// @ts-ignore @ember/modifier does not provide types :(
2-
import { on } from '@ember/modifier';
3-
import { setOwner } from '@ember/owner';
4-
import { click, render } from '@ember/test-helpers';
51
import { module, test } from 'qunit';
6-
import { setupRenderingTest, setupTest } from 'ember-qunit';
2+
import { setupTest } from 'ember-qunit';
73

84
import { resource } from 'ember-resources';
95

6+
import { compatOwner } from '../helpers';
7+
108
module('RAW', function (hooks) {
119
setupTest(hooks);
1210

1311
test('in plain js', async function (assert) {
1412
let thing = resource(() => 2);
1513
let parent = {};
1614

17-
setOwner(parent, this.owner);
15+
compatOwner.setOwner(parent, this.owner);
1816

17+
// @ts-expect-error - not sure what to bo about the type discrepency atm
1918
let instance = thing.create();
2019

2120
instance.link(parent);
@@ -26,6 +25,7 @@ module('RAW', function (hooks) {
2625
let thing = resource(() => 2);
2726

2827
assert.throws(() => {
28+
// @ts-expect-error - not sure what to bo about the type discrepency atm
2929
let instance = thing.create();
3030

3131
instance.current;
@@ -36,6 +36,7 @@ module('RAW', function (hooks) {
3636
let thing = resource(() => 2);
3737

3838
assert.throws(() => {
39+
// @ts-expect-error - not sure what to bo about the type discrepency atm
3940
let instance = thing.create();
4041

4142
instance.link({});

test-app/tests/helpers.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';
2+
3+
import type Owner from '@ember/owner';
4+
5+
interface CompatOwner {
6+
getOwner: (context: unknown) => Owner | undefined;
7+
setOwner: (context: unknown, owner: Owner) => void;
8+
}
9+
10+
export const compatOwner = {} as CompatOwner;
11+
12+
if (macroCondition(dependencySatisfies('ember-source', '>=4.12.0'))) {
13+
// In no version of ember where `@ember/owner` tried to be imported did it exist
14+
// if (macroCondition(false)) {
15+
// Using 'any' here because importSync can't lookup types correctly
16+
compatOwner.getOwner = (importSync('@ember/owner') as any).getOwner;
17+
compatOwner.setOwner = (importSync('@ember/owner') as any).setOwner;
18+
} else {
19+
// Using 'any' here because importSync can't lookup types correctly
20+
compatOwner.getOwner = (importSync('@ember/application') as any).getOwner;
21+
compatOwner.setOwner = (importSync('@ember/application') as any).setOwner;
22+
}

0 commit comments

Comments
 (0)