Skip to content

Commit

Permalink
small progress
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Apr 30, 2024
1 parent b5eaa95 commit fe9db66
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 32 deletions.
13 changes: 11 additions & 2 deletions packages/ember-testing/tests/reexports_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Ember from 'ember';
import { confirmExport } from 'internal-test-helpers';
import { confirmExport, testUnless } from 'internal-test-helpers';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
import * as emberTesting from 'ember-testing';
import { DEPRECATIONS } from '@ember/-internals/deprecations';

class ReexportsTestCase extends AbstractTestCase {}

Expand All @@ -19,7 +20,15 @@ class ReexportsTestCase extends AbstractTestCase {}
exportName = path;
}

ReexportsTestCase.prototype[`@test Ember.${path} exports correctly`] = function (assert) {
ReexportsTestCase.prototype[
`${testUnless(
DEPRECATIONS.DEPRECATE_IMPORT_EMBER(path).isRemoved
)} Ember.${path} exports correctly`
] = function (assert) {
expectDeprecation(
/'ember' barrel file is deprecated/,
DEPRECATIONS.DEPRECATE_IMPORT_EMBER(path).isEnabled
);
confirmExport(Ember, assert, path, moduleId, exportName, emberTesting);
};
});
Expand Down
68 changes: 42 additions & 26 deletions packages/ember/tests/reexports_test.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
import Ember from '../index';
import { FEATURES } from '@ember/canary-features';
import { AbstractTestCase, confirmExport, moduleFor } from 'internal-test-helpers';
import {
AbstractTestCase,
confirmExport,
expectDeprecation,
moduleFor,
testUnless,
} from 'internal-test-helpers';
import { DEBUG } from '@glimmer/env';

moduleFor(
'ember reexports',
class extends AbstractTestCase {
[`@test Ember exports correctly`](assert) {
allExports.forEach((reexport) => {
let [path, moduleId, exportName, mod] = reexport;
class ReExportTests extends AbstractTestCase {
[`${testUnless(
DEPRECATIONS.DEPRECATE_IMPORT_EMBER('---any---').isRemoved
)} Ember exports correctly`](assert) {
allExports.forEach((reexport) => {
let [path, moduleId, exportName, mod] = reexport;

// default path === exportName if none present
if (!exportName) {
exportName = path;
}
// default path === exportName if none present
if (!exportName) {
exportName = path;
}

confirmExport(Ember, assert, path, moduleId, exportName, mod);
});
}
confirmExport(Ember, assert, path, moduleId, exportName, mod);
});
}

'@test Ember.FEATURES is exported'(assert) {
if (Object.keys(FEATURES).length === 0) {
assert.expect(0);
}
[`${testUnless(
DEPRECATIONS.DEPRECATE_IMPORT_EMBER('FEATURES').isRemoved
)} Ember.FEATURES is exported`](assert) {
if (Object.keys(FEATURES).length === 0) {
assert.expect(0);
}

for (let feature in FEATURES) {
assert.equal(
Ember.FEATURES[feature],
FEATURES[feature],
'Ember.FEATURES contains ${feature} with correct value'
);
}
for (let feature in FEATURES) {
expectDeprecation(
() => {
assert.equal(
Ember.FEATURES[feature],
FEATURES[feature],
'Ember.FEATURES contains ${feature} with correct value'
);
},
/importing FEATURES from the 'ember' barrel file is deprecated/,
DEPRECATIONS.DEPRECATE_IMPORT_EMBER('FEATURES').isEnabled
);
}
}
);
}

moduleFor('ember reexports', ReExportTests);

import * as test0 from '@ember/application';
import * as test1 from '@ember/application/instance';
Expand Down Expand Up @@ -96,6 +111,7 @@ import * as test57 from '@ember/-internals/runtime';
import * as test58 from '@ember/-internals/routing';
import * as test59 from 'backburner.js';
import * as test60 from 'rsvp';
import { DEPRECATIONS } from '@ember/-internals/deprecations';

let allExports = [
['Application', '@ember/application', 'default', test0],
Expand Down
10 changes: 6 additions & 4 deletions packages/internal-test-helpers/lib/ember-dev/setup-qunit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getOnerror, setOnerror } from '@ember/-internals/error-handling';

import { getDebugFunction, setDebugFunction } from '@ember/debug';
import { DEBUG } from '@glimmer/env';

Expand Down Expand Up @@ -51,11 +53,11 @@ export default function setupQUnit() {
message?: string
) {
let error: unknown;
let prevOnError = window.onerror;
let prevOnError = getOnerror();

window.onerror = (e: string | Event) => {
setOnerror((e: Error) => {
error = e;
};
});

try {
await promise;
Expand All @@ -73,7 +75,7 @@ export default function setupQUnit() {
message
);

window.onerror = prevOnError;
setOnerror(prevOnError);
};

QUnit.assert.throwsAssertion = function (
Expand Down

0 comments on commit fe9db66

Please sign in to comment.