Skip to content

Commit

Permalink
Fix TS lint errors with deprecation helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
patocallaghan committed Feb 23, 2021
1 parent c3d95df commit 96a8a34
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
@@ -1,11 +1,10 @@
import {
ApplicationTestCase,
expectDeprecation,
ModuleBasedTestResolver,
moduleFor,
strip,
} from 'internal-test-helpers';
import { ExpectDeprecationFunc } from '../../../../../../internal-test-helpers/lib/ember-dev/deprecation';
declare let expectDeprecation: ExpectDeprecationFunc;

import { ENV } from '@ember/-internals/environment';
import { Component, setComponentManager } from '@ember/-internals/glimmer';
Expand Down
6 changes: 6 additions & 0 deletions packages/internal-test-helpers/index.js
Expand Up @@ -8,6 +8,12 @@ export { default as strip } from './lib/strip';
export { default as applyMixins } from './lib/apply-mixins';
export { default as getTextOf } from './lib/get-text-of';
export { default as maybeExpectDeprecation } from './lib/maybe-expect-deprecation';
export {
expectDeprecation,
expectNoDeprecation,
expectDeprecationAsync,
ignoreDeprecation,
} from './lib/ember-dev/deprecation';
export {
defineComponent,
defineSimpleHelper,
Expand Down
32 changes: 24 additions & 8 deletions packages/internal-test-helpers/lib/ember-dev/deprecation.ts
Expand Up @@ -35,6 +35,22 @@ export function setupDeprecationHelpers(hooks: NestedHooks, env: DebugEnv): void
});
}

export let expectDeprecation: ExpectDeprecationFunc = () => {
throw new Error('DeprecationAssert: To use `expectDeprecation` in a test you must call `setupDeprecationHelpers` first');
};

export let ignoreDeprecation: ExpectDeprecationFunc = () => {
throw new Error('DeprecationAssert: To use `ignoreDeprecation` in a test you must call `setupDeprecationHelpers` first');
};

export let expectDeprecationAsync: ExpectDeprecationFunc = () => {
throw new Error('DeprecationAssert: To use `expectDeprecationAsync` in a test you must call `setupDeprecationHelpers` first');
};

export let expectNoDeprecation: ExpectDeprecationFunc = () => {
throw new Error('DeprecationAssert: To use `expectNoDeprecation` in a test you must call `setupDeprecationHelpers` first');
};

class DeprecationAssert extends DebugAssert {
constructor(env: DebugEnv) {
super('deprecate', env);
Expand All @@ -51,7 +67,7 @@ class DeprecationAssert extends DebugAssert {
// expectNoDeprecation();
// Ember.deprecate("Old And Busted");
//
let expectNoDeprecation: ExpectNoDeprecationFunc = (func) => {
let expectNoDeprecationLocal: ExpectNoDeprecationFunc = (func) => {
if (typeof func !== 'function') {
func = undefined;
}
Expand All @@ -77,7 +93,7 @@ class DeprecationAssert extends DebugAssert {
// expectDeprecation(/* optionalStringOrRegex */);
// Ember.deprecate("Old And Busted");
//
let expectDeprecation: ExpectDeprecationFunc = (func, message) => {
let expectDeprecationLocal: ExpectDeprecationFunc = (func, message) => {
let actualFunc: (() => void) | undefined;
if (typeof func !== 'function') {
message = func as Message;
Expand All @@ -95,7 +111,7 @@ class DeprecationAssert extends DebugAssert {
});
};

let expectDeprecationAsync: ExpectDeprecationAsyncFunc = async (func, message) => {
let expectDeprecationAsyncLocal: ExpectDeprecationAsyncFunc = async (func, message) => {
let actualFunc: (() => void) | undefined;
if (typeof func !== 'function') {
message = func as Message;
Expand All @@ -117,14 +133,14 @@ class DeprecationAssert extends DebugAssert {
);
};

let ignoreDeprecation: IgnoreDeprecationFunc = (func) => {
let ignoreDeprecationLocal: IgnoreDeprecationFunc = (func) => {
callWithStub(this.env, 'deprecate', func);
};

window.expectNoDeprecation = expectNoDeprecation;
window.expectDeprecation = expectDeprecation;
window.expectDeprecationAsync = expectDeprecationAsync;
window.ignoreDeprecation = ignoreDeprecation;
window.expectNoDeprecation = expectNoDeprecation = expectNoDeprecationLocal;
window.expectDeprecation = expectDeprecation = expectDeprecationLocal;
window.expectDeprecationAsync = expectDeprecationAsync = expectDeprecationAsyncLocal;
window.ignoreDeprecation = ignoreDeprecation = ignoreDeprecationLocal;
}

restore(): void {
Expand Down

0 comments on commit 96a8a34

Please sign in to comment.