diff --git a/app/assets/javascripts/discourse/models/store.js.es6 b/app/assets/javascripts/discourse/models/store.js.es6 index b2f0225409c..753f2dd5abf 100644 --- a/app/assets/javascripts/discourse/models/store.js.es6 +++ b/app/assets/javascripts/discourse/models/store.js.es6 @@ -44,7 +44,7 @@ export default Ember.Object.extend({ init() { this._super(); - this.register = getRegister(this); + this.register = this.register || getRegister(this); }, pluralize(thing) { diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index bbffb5be37f..4c39f4a5421 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -318,14 +318,18 @@ export default createWidget('post-menu', { const $heart = $(`[data-post-id=${attrs.id}] .fa-heart`); $heart.closest('button').addClass('has-like'); - const scale = [1.0, 1.5]; - return new Ember.RSVP.Promise(resolve => { - animateHeart($heart, scale[0], scale[1], () => { - animateHeart($heart, scale[1], scale[0], () => { - this.sendWidgetAction('toggleLike').then(() => resolve()); + if (!Ember.testing) { + const scale = [1.0, 1.5]; + return new Ember.RSVP.Promise(resolve => { + animateHeart($heart, scale[0], scale[1], () => { + animateHeart($heart, scale[1], scale[0], () => { + this.sendWidgetAction('toggleLike').then(() => resolve()); + }); }); }); - }); + } else { + this.sendWidgetAction('toggleLike'); + } }, refreshLikes() { diff --git a/test/javascripts/components/text-field-test.js.es6 b/test/javascripts/components/text-field-test.js.es6 index 3b939913421..81b0660052b 100644 --- a/test/javascripts/components/text-field-test.js.es6 +++ b/test/javascripts/components/text-field-test.js.es6 @@ -1,17 +1,24 @@ -moduleForComponent("text-field", {needs: []}); +import componentTest from 'helpers/component-test'; -test("renders correctly with no properties set", function() { - var component = this.subject(); - equal(component.get('type'), "text"); +moduleForComponent("text-field", { integration: true }); + +componentTest("renders correctly with no properties set", { + template: `{{text-field}}`, + + test(assert) { + assert.ok(this.$('input[type=text]').length); + } }); -test("support a placeholder", function() { - sandbox.stub(I18n, "t").returnsArg(0); +componentTest("support a placeholder", { + template: `{{text-field placeholderKey="placeholder.i18n.key"}}`, - var component = this.subject({ - placeholderKey: "placeholder.i18n.key" - }); + setup() { + sandbox.stub(I18n, "t").returnsArg(0); + }, - equal(component.get('type'), "text"); - equal(component.get('placeholder'), "placeholder.i18n.key"); + test(assert) { + assert.ok(this.$('input[type=text]').length); + assert.equal(this.$('input').prop('placeholder'), 'placeholder.i18n.key'); + } }); diff --git a/test/javascripts/helpers/component-test.js.es6 b/test/javascripts/helpers/component-test.js.es6 index 69b6b67ab01..be0be14a73f 100644 --- a/test/javascripts/helpers/component-test.js.es6 +++ b/test/javascripts/helpers/component-test.js.es6 @@ -36,10 +36,24 @@ export default function(name, opts) { this.registry.register('store:main', store, { instantiate: false }); if (opts.setup) { + if (Ember.VERSION[0] === "2") { + // use closure actions instead + this.on = (actionName, fn) => this.set(actionName, fn); + } + opts.setup.call(this, store); } - andThen(() => this.render(opts.template)); + andThen(() => { + // TODO: This shouldn't be necessary + this.owner = { + hasRegistration: (...args) => this.registry.has(...args), + lookup: (...args) => this.container.lookup(...args), + _lookupFactory: (...args) => this.container.lookupFactory(...args) + }; + + return this.render(opts.template); + }); andThen(() => opts.test.call(this, assert)); }); } diff --git a/test/javascripts/helpers/create-store.js.es6 b/test/javascripts/helpers/create-store.js.es6 index 37df69372f8..9ad8d169c51 100644 --- a/test/javascripts/helpers/create-store.js.es6 +++ b/test/javascripts/helpers/create-store.js.es6 @@ -6,8 +6,9 @@ import { buildResolver } from 'discourse-common/resolver'; export default function() { const resolver = buildResolver('discourse').create(); + return Store.create({ - container: { + register: { lookup(type) { if (type === "adapter:rest") { this._restAdapter = this._restAdapter || RestAdapter.create({ container: this });