faster tests

This commit is contained in:
Joffrey JAFFEUX 2017-07-19 13:15:18 +02:00
parent b83f430ef0
commit c99a5bce8f
2 changed files with 23 additions and 31 deletions

View File

@ -111,7 +111,7 @@ export default Ember.Component.extend({
this._bindEvents(); this._bindEvents();
Ember.run.later(this, function() { this._later(this, function() {
this._setDiversity(); this._setDiversity();
this._positionPicker(); this._positionPicker();
this._scrollTo(); this._scrollTo();
@ -119,6 +119,14 @@ export default Ember.Component.extend({
}); });
}, },
_later(context, handler, timeout) {
if(Ember.testing) {
handler.bind(context)();
} else {
Ember.run.later(context, handler, timeout);
}
},
_bindEvents() { _bindEvents() {
this._bindDiversityClick(); this._bindDiversityClick();
this._bindSectionsScroll(); this._bindSectionsScroll();
@ -293,7 +301,7 @@ export default Ember.Component.extend({
if(preloadedSection && !preloadedSection.$section.hasClass("loaded")) { if(preloadedSection && !preloadedSection.$section.hasClass("loaded")) {
preloadedSection.$section.addClass("loaded"); preloadedSection.$section.addClass("loaded");
const $visibleEmojis = preloadedSection.$section.find(".emoji[src='']"); const $visibleEmojis = preloadedSection.$section.find(".emoji[src='']");
Ember.run.later(() => { this._loadVisibleEmojis($visibleEmojis); }, 1500); this._later(this, function() { this._loadVisibleEmojis($visibleEmojis) }, 1500)
} }
} }
}, },

View File

@ -112,42 +112,26 @@ QUnit.test("emoji picker has a list of recently used emojis", assert => {
"it adds the emoji code to the recently used emojis list" "it adds the emoji code to the recently used emojis list"
); );
}); });
});
QUnit.test("emoji picker can clear recently used emojis", assert => { click(".emoji-picker .clear-recent");
visit("/t/internationalization-localization/280");
click("#topic-footer-buttons .btn.create");
click("button.emoji.btn");
click(".emoji-picker a[title='grinning']");
click(".emoji-picker a[title='sunglasses']");
click(".emoji-picker a[title='sunglasses']");
andThen(() => { andThen(() => {
assert.equal( assert.equal(
find('.section[data-section="recent"] .section-group img.emoji').length, find('.section[data-section="recent"] .section-group img.emoji').length,
2 0,
"it has cleared recent emojis"
); );
click(".emoji-picker .clear-recent"); assert.equal(
andThen(() => { find('.section[data-section="recent"]').css("display"),
assert.equal( "none",
find('.section[data-section="recent"] .section-group img.emoji').length, "it hides recent section"
0, );
"it has cleared recent emojis"
);
assert.equal( assert.equal(
find('.section[data-section="recent"]').css("display"), find('.category-icon a[title="recent"]').parent().css("display"),
"none", "none",
"it hides recent section" "it hides recent category icon"
); );
assert.equal(
find('.category-icon a[title="recent"]').parent().css("display"),
"none",
"it hides recent category icon"
);
});
}); });
}); });