From 8dc6dff0dc93177ef359bfed8ccffb18a677c9d5 Mon Sep 17 00:00:00 2001 From: Mike North Date: Mon, 15 Oct 2018 15:43:57 -0700 Subject: [PATCH] [@ember/object] remove all 'import ember' from tests (#29761) --- types/ember__object/test/core.ts | 258 ++++++++++---------- types/ember__object/test/create-negative.ts | 1 - 2 files changed, 135 insertions(+), 124 deletions(-) diff --git a/types/ember__object/test/core.ts b/types/ember__object/test/core.ts index 984f5eec12..740daa78b0 100644 --- a/types/ember__object/test/core.ts +++ b/types/ember__object/test/core.ts @@ -1,8 +1,8 @@ -import Ember from 'ember'; import { assertType } from './lib/assert'; +import CoreObject from '@ember/object/core'; /** Newable tests */ -const co1 = new Ember.CoreObject(); +const co1 = new CoreObject(); // TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 // co1.concatenatedProperties; // $ExpectType string[] @@ -12,7 +12,7 @@ co1.destroy(); // $ExpectType CoreObject co1.toString(); // $ExpectType string /** .create tests */ -const co2 = Ember.CoreObject.create(); +const co2 = CoreObject.create(); // TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 // co2.concatenatedProperties; // $ExpectType string[] co2.isDestroyed; // $ExpectType boolean @@ -21,13 +21,13 @@ co2.destroy(); // $ExpectType CoreObject co2.toString(); // $ExpectType string /** .create tests w/ initial instance data passed in */ -const co3 = Ember.CoreObject.create({ foo: '123', bar: 456 }); +const co3 = CoreObject.create({ foo: '123', bar: 456 }); co3.foo; // $ExpectType string co3.bar; // $ExpectType number /** .extend with a zero-argument .create() */ -const co4 = Ember.CoreObject.extend({ +const co4 = CoreObject.extend({ foo: '123', bar: 456, baz(): [string, number] { @@ -40,8 +40,8 @@ co4.bar; // $ExpectType number co4.baz; // $ExpectType () => [string, number] /** .extend with inconsistent arguments passed into .create() */ -const class05 = Ember.CoreObject.extend({ - foo: '123' as (string | boolean), +const class05 = CoreObject.extend({ + foo: '123' as string | boolean, bar: 456, baz() { return [this.foo, this.bar]; @@ -54,33 +54,36 @@ assertType(c05b.foo); // $ExpectError assertType(c05c.foo); // $ExpectError /** two .extend arguments with a zero-argument .create() */ -const co6 = Ember.CoreObject.extend({ - foo: '123', - bar: 456, - baz() { - return [this.foo, this.bar]; +const co6 = CoreObject.extend( + { + foo: '123', + bar: 456, + baz() { + return [this.foo, this.bar]; + }, + func1() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.foo; // $ExpectType string + // this does not include stuff from later extend args + this.bee; // $ExpectError + } }, - func1() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.foo; // $ExpectType string - // this does not include stuff from later extend args - this.bee; // $ExpectError + { + foo: 99, + bee: 'honey', + func2() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 + this.foo; // $ExpectType string & number + // this includes stuff from earlier extend-args + this.bar; // $ExpectType number + } } -}, { - foo: 99, - bee: 'honey', - func2() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 - this.foo; // $ExpectType string & number - // this includes stuff from earlier extend-args - this.bar; // $ExpectType number - } -}).create(); +).create(); // TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 // assertType(co6.foo); // $ExpectError @@ -88,45 +91,49 @@ assertType(co6.bar); // $ExpectType number assertType<() => Array>(co6.baz); // $ExpectType () => (string | number)[] /** three .extend arguments with a zero-argument .create() */ -const co7 = Ember.CoreObject.extend({ - foo: '123', - bar: 456, - baz() { - return [this.foo, this.bar]; +const co7 = CoreObject.extend( + { + foo: '123', + bar: 456, + baz() { + return [this.foo, this.bar]; + }, + func1() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.foo; // $ExpectType string + // this does not include stuff from later extend args + this.bee; // $ExpectError + } }, - func1() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.foo; // $ExpectType string - // this does not include stuff from later extend args - this.bee; // $ExpectError + { + foo: 99, + bee: 'honey', + func2() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 + this.foo; // $ExpectType string & number + // this includes stuff from earlier extend-args + this.bar; // $ExpectType number + } + }, + { + foo: '99', + money: 'in the banana stand', + func3() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.money; // $ExpectType string + // this includes stuff from earlier extend-args + this.bee; // $ExpectType string + this.bar; // $ExpectType number + } } -}, { - foo: 99, - bee: 'honey', - func2() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 - this.foo; // $ExpectType string & number - // this includes stuff from earlier extend-args - this.bar; // $ExpectType number - } -}, { - foo: '99', - money: 'in the banana stand', - func3() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.money; // $ExpectType string - // this includes stuff from earlier extend-args - this.bee; // $ExpectType string - this.bar; // $ExpectType number - } -}).create(); +).create(); // TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 // assertType(co7.foo); // $ExpectError assertType(co7.bar); // $ExpectType number @@ -134,62 +141,67 @@ assertType(co7.money); // $ExpectType string assertType<() => Array>(co7.baz); // $ExpectType () => (string | number)[] /** four .extend arguments with a zero-argument .create() */ -const co8 = Ember.CoreObject.extend({ - foo: '123', - bar: 456, - baz() { - return [this.foo, this.bar]; +const co8 = CoreObject.extend( + { + foo: '123', + bar: 456, + baz() { + return [this.foo, this.bar]; + }, + func1() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.foo; // $ExpectType string + // this does not include stuff from later extend args + this.bee; // $ExpectError + } }, - func1() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.foo; // $ExpectType string - // this does not include stuff from later extend args - this.bee; // $ExpectError + { + foo: 99, + bee: 'honey', + func2() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 + this.foo; // $ExpectType string & number + // this includes stuff from earlier extend-args + this.bar; // $ExpectType number + // this does not include stuff from later extend args + this.money; // $ExpectError + } + }, + { + foo: '99', + money: 'in the banana stand', + func3() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.money; // $ExpectType string + // this includes stuff from earlier extend-args + this.bee; // $ExpectType string + this.bar; // $ExpectType number + // this does not include stuff from later extend args + this.neighborhood; // $ExpectError + } + }, + { + foo: '99', + neighborhood: 'sudden valley', + func4() { + // this includes stuff from CoreObject + this.init; // $ExpectType () => void + // this includes stuff from this extend-arg + this.neighborhood; // $ExpectType string + // this includes stuff from earlier extend-args + this.bee; // $ExpectType string + this.bar; // $ExpectType number + this.money; // $ExpectType string + } } -}, { - foo: 99, - bee: 'honey', - func2() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 - this.foo; // $ExpectType string & number - // this includes stuff from earlier extend-args - this.bar; // $ExpectType number - // this does not include stuff from later extend args - this.money; // $ExpectError - } -}, { - foo: '99', - money: 'in the banana stand', - func3() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.money; // $ExpectType string - // this includes stuff from earlier extend-args - this.bee; // $ExpectType string - this.bar; // $ExpectType number - // this does not include stuff from later extend args - this.neighborhood; // $ExpectError - } -}, { - foo: '99', - neighborhood: 'sudden valley', - func4() { - // this includes stuff from CoreObject - this.init; // $ExpectType () => void - // this includes stuff from this extend-arg - this.neighborhood; // $ExpectType string - // this includes stuff from earlier extend-args - this.bee; // $ExpectType string - this.bar; // $ExpectType number - this.money; // $ExpectType string - } -}).create(); +).create(); // TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291 // assertType(co8.foo); // $ExpectError diff --git a/types/ember__object/test/create-negative.ts b/types/ember__object/test/create-negative.ts index 2298ae8cf3..dadd2a2176 100644 --- a/types/ember__object/test/create-negative.ts +++ b/types/ember__object/test/create-negative.ts @@ -1,5 +1,4 @@ import { assertType } from './lib/assert'; -import Ember from 'ember'; import { PersonWithNumberName, Person } from './create'; Person.create({ firstName: 99 }); // $ExpectError