mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:50:26 -06:00
Update code so Ember 2.3 can have more tests passing
This commit is contained in:
parent
78cd42943f
commit
151597bf0f
@ -44,7 +44,7 @@ export default Ember.Object.extend({
|
||||
|
||||
init() {
|
||||
this._super();
|
||||
this.register = getRegister(this);
|
||||
this.register = this.register || getRegister(this);
|
||||
},
|
||||
|
||||
pluralize(thing) {
|
||||
|
@ -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() {
|
||||
|
@ -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');
|
||||
}
|
||||
});
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
@ -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 });
|
||||
|
Loading…
Reference in New Issue
Block a user