Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
thoov committed Feb 8, 2018
1 parent ec65b11 commit 4cda289
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Hi Max 9');
}

['@test nested components positional parameters override named parameters [DEPRECATED]']() {
['@test nested components positional parameters override named parameters [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name', 'age']
}),
template: '{{name}} {{age}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render('{{component (component (component "-looked-up" "Sergio" 29) name="Marvin" age=21)}}');
}, 'You cannot specify both a positional param (at position 1) and the hash argument `age`.');

Expand All @@ -337,15 +337,15 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Sergio 29');
}

['@test nested components with positional params at outer layer are override hash parameters [DEPRECATED]']() {
['@test nested components with positional params at outer layer are override hash parameters [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age']
}),
template: '{{greeting}} {{name}} {{age}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" "Hola" "Dolores" 33) as |first|}}
Expand All @@ -368,7 +368,7 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Hola Dolores 33');
}

['@test nested components with positional params at middle layer partially override hash parameters [DEPRECATED]']() {
['@test nested components with positional params at middle layer partially override hash parameters [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age']
Expand All @@ -377,7 +377,7 @@ moduleFor('Components test: contextual components', class extends RenderingTest
template: '{{greeting}} {{name}} {{age}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
Expand All @@ -400,7 +400,7 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Hej Sigmundur 33');
}

['@test nested components with positional params at invocation override earlier hash parameters [DEPRECATED]']() {
['@test nested components with positional params at invocation override earlier hash parameters [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['greeting', 'name', 'age']
Expand All @@ -409,7 +409,7 @@ moduleFor('Components test: contextual components', class extends RenderingTest
template: '{{greeting}} {{name}} {{age}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render(
strip`
{{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}
Expand Down Expand Up @@ -560,15 +560,15 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Inner 28');
}

['@test conflicting positional and hash parameters trigger a deprecation if in the same component context [DEPRECATED]']() {
['@test conflicting positional and hash parameters trigger a deprecation if in the same component context [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render('{{component (component "-looked-up" "Hodari" name="Sergio") "Hodari" greeting="Hodi"}}');
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');
}
Expand Down Expand Up @@ -604,15 +604,15 @@ moduleFor('Components test: contextual components', class extends RenderingTest
this.assertText('Hodi Hodari');
}

['@test conflicting positional and hash parameters trigger a deprecation [DEPRECATED]']() {
['@test conflicting positional and hash parameters trigger a deprecation [DEPRECATED]'](assert) {
this.registerComponent('-looked-up', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render('{{component (component "-looked-up" "Hodari") name="Sergio" greeting="Hodi"}}');
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1684,15 +1684,15 @@ moduleFor('Components test: curly components', class extends RenderingTest {
this.assertText('Quint4');
}

['@test if a value is passed as a non-positional parameter, it raises an assertion']() {
['@test if a value is passed as a non-positional parameter, it raises an assertion'](assert) {
this.registerComponent('sample-component', {
ComponentClass: Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{name}}'
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
this.render('{{sample-component notMyName name=myName}}', {
myName: 'Quint',
notMyName: 'Sergio'
Expand Down Expand Up @@ -3200,4 +3200,4 @@ if (jQueryDisabled) {
}

});
}
}
39 changes: 32 additions & 7 deletions packages/ember-metal/tests/mixin/required_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ let PartialMixin, FinalMixin, obj;
let originalEnvVal;

moduleFor('Module.required', class extends AbstractTestCase {
beforeEach(assert) {
beforeEach() {
originalEnvVal = ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT;
ENV._ENABLE_PROPERTY_REQUIRED_SUPPORT = true;
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');

FinalMixin = Mixin.create({
foo: 'FOO'
Expand All @@ -34,28 +28,59 @@ moduleFor('Module.required', class extends AbstractTestCase {
}

['@test applying a mixin to meet requirement'](assert) {
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');

FinalMixin.apply(obj);
PartialMixin.apply(obj);
assert.equal(get(obj, 'foo'), 'FOO', 'should now be defined');
}

['@test combined mixins to meet requirement'](assert) {
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');
Mixin.create(PartialMixin, FinalMixin).apply(obj);
assert.equal(get(obj, 'foo'), 'FOO', 'should now be defined');
}

['@test merged mixin'](assert) {
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');
Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj);
assert.equal(get(obj, 'foo'), 'FOO', 'should now be defined');
}

['@test define property on source object'](assert) {
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');
obj.foo = 'FOO';
PartialMixin.apply(obj);
assert.equal(get(obj, 'foo'), 'FOO', 'should now be defined');
}

['@test using apply'](assert) {
assert.expectDeprecation(() => {
PartialMixin = Mixin.create({
foo: required(),
bar: 'BAR'
});
}, 'Ember.required is deprecated as its behavior is inconsistent and unreliable.');
mixin(obj, PartialMixin, { foo: 'FOO' });
assert.equal(get(obj, 'foo'), 'FOO', 'should now be defined');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-metal/tests/run_loop/schedule_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ moduleFor('system/run_loop/schedule_test', class extends AbstractTestCase {
let runLoop = run.currentRunLoop;
assert.ok(runLoop, 'run loop present');

expectDeprecation(() => {
assert.expectDeprecation(() => {
run.schedule('sync', () => {
order.push('sync');
assert.equal(runLoop, run.currentRunLoop, 'same run loop used');
Expand All @@ -64,7 +64,7 @@ moduleFor('system/run_loop/schedule_test', class extends AbstractTestCase {
assert.equal(runLoop, run.currentRunLoop, 'same run loop used');
});

expectDeprecation(() => {
assert.expectDeprecation(() => {
run.schedule('sync', () => {
order.push('sync');
assert.equal(runLoop, run.currentRunLoop, 'same run loop used');
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-metal/tests/run_loop/sync_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ moduleFor('system/run_loop/sync_test', class extends AbstractTestCase {

function syncfunc() {
if (++cnt < 5) {
expectDeprecation(() => {
assert.expectDeprecation(() => {
run.schedule('sync', syncfunc);
}, `Scheduling into the 'sync' run loop queue is deprecated.`);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-runtime/tests/mixins/observable_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ QUnit.test('incrementProperty should work even if value is number in string', fu
assert.equal(25, obj.get('age'));
});

QUnit.test('propertyWillChange triggers a deprecation warning', function () {
QUnit.test('propertyWillChange triggers a deprecation warning', function (assert) {
let obj = EmberObject.create();

expectDeprecation(() => {
assert.expectDeprecation(() => {
obj.propertyWillChange('foo');
}, /'propertyWillChange' is deprecated and has no effect. It is safe to remove this call./);
});

QUnit.test('propertyDidChange triggers a deprecation warning', function () {
QUnit.test('propertyDidChange triggers a deprecation warning', function (assert) {
let obj = EmberObject.create();

expectDeprecation(() => {
assert.expectDeprecation(() => {
obj.propertyDidChange('foo');
}, /'propertyDidChange' is deprecated in favor of 'notifyPropertyChange'. It is safe to change this call to 'notifyPropertyChange'./);
});
5 changes: 5 additions & 0 deletions packages/internal-test-helpers/lib/ember-dev/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ export function assertNoDeprecations(qunitAssert, deprecations) {
message: `Expected no deprecations during test, but deprecations were found.\n${deprecationStr}`
});
}


export function assertionHandler() {

}
Empty file.

0 comments on commit 4cda289

Please sign in to comment.