mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 06:09:30 +08: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() {
|
init() {
|
||||||
this._super();
|
this._super();
|
||||||
this.register = getRegister(this);
|
this.register = this.register || getRegister(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
pluralize(thing) {
|
pluralize(thing) {
|
||||||
|
|
|
@ -318,6 +318,7 @@ export default createWidget('post-menu', {
|
||||||
const $heart = $(`[data-post-id=${attrs.id}] .fa-heart`);
|
const $heart = $(`[data-post-id=${attrs.id}] .fa-heart`);
|
||||||
$heart.closest('button').addClass('has-like');
|
$heart.closest('button').addClass('has-like');
|
||||||
|
|
||||||
|
if (!Ember.testing) {
|
||||||
const scale = [1.0, 1.5];
|
const scale = [1.0, 1.5];
|
||||||
return new Ember.RSVP.Promise(resolve => {
|
return new Ember.RSVP.Promise(resolve => {
|
||||||
animateHeart($heart, scale[0], scale[1], () => {
|
animateHeart($heart, scale[0], scale[1], () => {
|
||||||
|
@ -326,6 +327,9 @@ export default createWidget('post-menu', {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.sendWidgetAction('toggleLike');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshLikes() {
|
refreshLikes() {
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
moduleForComponent("text-field", {needs: []});
|
import componentTest from 'helpers/component-test';
|
||||||
|
|
||||||
test("renders correctly with no properties set", function() {
|
moduleForComponent("text-field", { integration: true });
|
||||||
var component = this.subject();
|
|
||||||
equal(component.get('type'), "text");
|
componentTest("renders correctly with no properties set", {
|
||||||
|
template: `{{text-field}}`,
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.ok(this.$('input[type=text]').length);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("support a placeholder", function() {
|
componentTest("support a placeholder", {
|
||||||
|
template: `{{text-field placeholderKey="placeholder.i18n.key"}}`,
|
||||||
|
|
||||||
|
setup() {
|
||||||
sandbox.stub(I18n, "t").returnsArg(0);
|
sandbox.stub(I18n, "t").returnsArg(0);
|
||||||
|
},
|
||||||
|
|
||||||
var component = this.subject({
|
test(assert) {
|
||||||
placeholderKey: "placeholder.i18n.key"
|
assert.ok(this.$('input[type=text]').length);
|
||||||
});
|
assert.equal(this.$('input').prop('placeholder'), 'placeholder.i18n.key');
|
||||||
|
}
|
||||||
equal(component.get('type'), "text");
|
|
||||||
equal(component.get('placeholder'), "placeholder.i18n.key");
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,10 +36,24 @@ export default function(name, opts) {
|
||||||
this.registry.register('store:main', store, { instantiate: false });
|
this.registry.register('store:main', store, { instantiate: false });
|
||||||
|
|
||||||
if (opts.setup) {
|
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);
|
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));
|
andThen(() => opts.test.call(this, assert));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@ import { buildResolver } from 'discourse-common/resolver';
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
const resolver = buildResolver('discourse').create();
|
const resolver = buildResolver('discourse').create();
|
||||||
|
|
||||||
return Store.create({
|
return Store.create({
|
||||||
container: {
|
register: {
|
||||||
lookup(type) {
|
lookup(type) {
|
||||||
if (type === "adapter:rest") {
|
if (type === "adapter:rest") {
|
||||||
this._restAdapter = this._restAdapter || RestAdapter.create({ container: this });
|
this._restAdapter = this._restAdapter || RestAdapter.create({ container: this });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user