0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Resolved "Use defineProperty to define computed properties" deprecations

refs https://github.com/TryGhost/Ghost/issues/10310
- https://www.emberjs.com/deprecations/v3.x/#toc_ember-meta-descriptor-on-object
- required to allow upgrading to Ember > 3.5
This commit is contained in:
Kevin Ansfield 2019-03-05 18:13:47 +00:00
parent c4d16d5d67
commit 0d311ce03a
2 changed files with 25 additions and 23 deletions

View file

@ -1,5 +1,6 @@
import hbs from 'htmlbars-inline-precompile'; import hbs from 'htmlbars-inline-precompile';
import {click, find, render, settled} from '@ember/test-helpers'; import {click, find, render, settled} from '@ember/test-helpers';
import {defineProperty} from '@ember/object';
import {describe, it} from 'mocha'; import {describe, it} from 'mocha';
import {expect} from 'chai'; import {expect} from 'chai';
import {run} from '@ember/runloop'; import {run} from '@ember/runloop';
@ -37,13 +38,13 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('shows spinner whilst running', async function () { it('shows spinner whilst running', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
})); }));
await render(hbs`{{gh-task-button task=myTask}}`); await render(hbs`{{gh-task-button task=myTask}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.have.descendants('svg'); expect(find('button')).to.have.descendants('svg');
@ -53,13 +54,13 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('shows running text when passed whilst running', async function () { it('shows running text when passed whilst running', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
})); }));
await render(hbs`{{gh-task-button task=myTask runningText="Running"}}`); await render(hbs`{{gh-task-button task=myTask runningText="Running"}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.have.descendants('svg'); expect(find('button')).to.have.descendants('svg');
@ -71,14 +72,14 @@ describe('Integration: Component: gh-task-button', function () {
// skipped due to random failures on Travis - https://github.com/TryGhost/Ghost/issues/10308 // skipped due to random failures on Travis - https://github.com/TryGhost/Ghost/issues/10308
it.skip('appears disabled whilst running', async function () { it.skip('appears disabled whilst running', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
})); }));
await render(hbs`{{gh-task-button task=myTask}}`); await render(hbs`{{gh-task-button task=myTask}}`);
expect(find('button'), 'initial class').to.not.have.class('appear-disabled'); expect(find('button'), 'initial class').to.not.have.class('appear-disabled');
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button'), 'running class').to.have.class('appear-disabled'); expect(find('button'), 'running class').to.have.class('appear-disabled');
@ -92,14 +93,14 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('shows success on success', async function () { it('shows success on success', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
return true; return true;
})); }));
await render(hbs`{{gh-task-button task=myTask}}`); await render(hbs`{{gh-task-button task=myTask}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.have.class('gh-btn-green'); expect(find('button')).to.have.class('gh-btn-green');
@ -110,14 +111,14 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('assigns specified success class on success', async function () { it('assigns specified success class on success', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
return true; return true;
})); }));
await render(hbs`{{gh-task-button task=myTask successClass="im-a-success"}}`); await render(hbs`{{gh-task-button task=myTask successClass="im-a-success"}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.not.have.class('gh-btn-green'); expect(find('button')).to.not.have.class('gh-btn-green');
@ -129,7 +130,7 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('shows failure when task errors', async function () { it('shows failure when task errors', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
try { try {
yield timeout(50); yield timeout(50);
throw new ReferenceError('test error'); throw new ReferenceError('test error');
@ -140,7 +141,7 @@ describe('Integration: Component: gh-task-button', function () {
await render(hbs`{{gh-task-button task=myTask}}`); await render(hbs`{{gh-task-button task=myTask}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.have.class('gh-btn-red'); expect(find('button')).to.have.class('gh-btn-red');
@ -151,14 +152,14 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('shows failure on falsy response', async function () { it('shows failure on falsy response', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
return false; return false;
})); }));
await render(hbs`{{gh-task-button task=myTask}}`); await render(hbs`{{gh-task-button task=myTask}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.have.class('gh-btn-red'); expect(find('button')).to.have.class('gh-btn-red');
@ -169,14 +170,14 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it('assigns specified failure class on failure', async function () { it('assigns specified failure class on failure', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
return false; return false;
})); }));
await render(hbs`{{gh-task-button task=myTask failureClass="im-a-failure"}}`); await render(hbs`{{gh-task-button task=myTask failureClass="im-a-failure"}}`);
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
expect(find('button')).to.not.have.class('gh-btn-red'); expect(find('button')).to.not.have.class('gh-btn-red');
@ -190,7 +191,7 @@ describe('Integration: Component: gh-task-button', function () {
it('performs task on click', async function () { it('performs task on click', async function () {
let taskCount = 0; let taskCount = 0;
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
taskCount = taskCount + 1; taskCount = taskCount + 1;
})); }));
@ -204,7 +205,7 @@ describe('Integration: Component: gh-task-button', function () {
}); });
it.skip('keeps button size when showing spinner', async function () { it.skip('keeps button size when showing spinner', async function () {
this.set('myTask', task(function* () { defineProperty(this, 'myTask', task(function* () {
yield timeout(50); yield timeout(50);
})); }));
@ -213,7 +214,7 @@ describe('Integration: Component: gh-task-button', function () {
let height = find('button').clientHeight; let height = find('button').clientHeight;
expect(find('button')).to.not.have.attr('style'); expect(find('button')).to.not.have.attr('style');
this.get('myTask').perform(); this.myTask.perform();
run.later(this, function () { run.later(this, function () {
// we can't test exact width/height because Chrome/Firefox use different rounding methods // we can't test exact width/height because Chrome/Firefox use different rounding methods

View file

@ -1,5 +1,6 @@
import EmberObject from '@ember/object'; import EmberObject from '@ember/object';
import RSVP from 'rsvp'; import RSVP from 'rsvp';
import {defineProperty} from '@ember/object';
import {describe, it} from 'mocha'; import {describe, it} from 'mocha';
import {expect} from 'chai'; import {expect} from 'chai';
import {settled} from '@ember/test-helpers'; import {settled} from '@ember/test-helpers';
@ -59,7 +60,7 @@ describe('Unit: Controller: editor', function () {
let {controller} = this; let {controller} = this;
controller.set('target', {send() {}}); controller.set('target', {send() {}});
controller.set('generateSlug', task(function * () { defineProperty(controller, 'generateSlug', task(function * () {
this.set('post.slug', 'test-slug'); this.set('post.slug', 'test-slug');
yield RSVP.resolve(); yield RSVP.resolve();
})); }));
@ -79,7 +80,7 @@ describe('Unit: Controller: editor', function () {
let {controller} = this; let {controller} = this;
controller.set('target', {send() {}}); controller.set('target', {send() {}});
controller.set('generateSlug', task(function * () { defineProperty(controller, 'generateSlug', task(function * () {
this.set('post.slug', 'test-slug'); this.set('post.slug', 'test-slug');
yield RSVP.resolve(); yield RSVP.resolve();
})); }));
@ -100,7 +101,7 @@ describe('Unit: Controller: editor', function () {
let {controller} = this; let {controller} = this;
controller.set('target', {send() {}}); controller.set('target', {send() {}});
controller.set('generateSlug', task(function * () { defineProperty(controller, 'generateSlug', task(function * () {
expect(false, 'generateSlug should not be called').to.equal(true); expect(false, 'generateSlug should not be called').to.equal(true);
yield RSVP.resolve(); yield RSVP.resolve();
})); }));
@ -124,7 +125,7 @@ describe('Unit: Controller: editor', function () {
let {controller} = this; let {controller} = this;
controller.set('target', {send() {}}); controller.set('target', {send() {}});
controller.set('generateSlug', task(function * () { defineProperty(controller, 'generateSlug', task(function * () {
expect(false, 'generateSlug should not be called').to.equal(true); expect(false, 'generateSlug should not be called').to.equal(true);
yield RSVP.resolve(); yield RSVP.resolve();
})); }));