FIX: Broken tests in phantom, not in browser
This commit is contained in:
parent
e2b5919579
commit
52579179bd
|
@ -276,8 +276,8 @@ export default Ember.Component.extend({
|
||||||
if (!this.get('ready')) { return; }
|
if (!this.get('ready')) { return; }
|
||||||
|
|
||||||
const textarea = this.$('textarea.d-editor-input')[0];
|
const textarea = this.$('textarea.d-editor-input')[0];
|
||||||
let start = textarea.selectionStart;
|
const start = textarea.selectionStart;
|
||||||
let end = textarea.selectionEnd;
|
const end = textarea.selectionEnd;
|
||||||
|
|
||||||
const value = textarea.value.substring(start, end);
|
const value = textarea.value.substring(start, end);
|
||||||
const pre = textarea.value.slice(0, start);
|
const pre = textarea.value.slice(0, start);
|
||||||
|
|
|
@ -39,7 +39,7 @@ function initializeUngroupedIcons() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function trackEmojiUsage(title) {
|
function trackEmojiUsage(title) {
|
||||||
const recent = keyValueStore.getObject(EMOJI_USAGE);
|
const recent = keyValueStore.getObject(EMOJI_USAGE) || {};
|
||||||
|
|
||||||
if (!recent[title]) { recent[title] = { title: title, usage: 0 }; }
|
if (!recent[title]) { recent[title] = { title: title, usage: 0 }; }
|
||||||
recent[title]["usage"]++;
|
recent[title]["usage"]++;
|
||||||
|
|
|
@ -43,6 +43,12 @@ componentTest('updating the value refreshes the preview', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function jumpEnd(textarea) {
|
||||||
|
textarea.selectionStart = textarea.value.length;
|
||||||
|
textarea.selectionEnd = textarea.value.length;
|
||||||
|
return textarea;
|
||||||
|
}
|
||||||
|
|
||||||
function testCase(title, testFunc) {
|
function testCase(title, testFunc) {
|
||||||
componentTest(title, {
|
componentTest(title, {
|
||||||
template: '{{d-editor value=value}}',
|
template: '{{d-editor value=value}}',
|
||||||
|
@ -50,13 +56,14 @@ function testCase(title, testFunc) {
|
||||||
this.set('value', 'hello world.');
|
this.set('value', 'hello world.');
|
||||||
},
|
},
|
||||||
test(assert) {
|
test(assert) {
|
||||||
const textarea = this.$('textarea.d-editor-input')[0];
|
const textarea = jumpEnd(this.$('textarea.d-editor-input')[0]);
|
||||||
testFunc.call(this, assert, textarea);
|
testFunc.call(this, assert, textarea);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
testCase(`bold button with no selection`, function(assert, textarea) {
|
testCase(`bold button with no selection`, function(assert, textarea) {
|
||||||
|
console.log(textarea.selectionStart);
|
||||||
click(`button.bold`);
|
click(`button.bold`);
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
const example = I18n.t(`composer.bold_text`);
|
const example = I18n.t(`composer.bold_text`);
|
||||||
|
@ -203,7 +210,7 @@ componentTest('code button', {
|
||||||
},
|
},
|
||||||
|
|
||||||
test(assert) {
|
test(assert) {
|
||||||
const textarea = this.$('textarea.d-editor-input')[0];
|
const textarea = jumpEnd(this.$('textarea.d-editor-input')[0]);
|
||||||
|
|
||||||
click('button.code');
|
click('button.code');
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
|
@ -403,6 +410,8 @@ testCase(`heading button with no selection`, function(assert, textarea) {
|
||||||
assert.equal(textarea.selectionEnd, 17 + example.length);
|
assert.equal(textarea.selectionEnd, 17 + example.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
textarea.selectionStart = 30;
|
||||||
|
textarea.selectionEnd = 30;
|
||||||
click(`button.heading`);
|
click(`button.heading`);
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.equal(this.get('value'), `hello world.\n\n${example}`);
|
assert.equal(this.get('value'), `hello world.\n\n${example}`);
|
||||||
|
@ -468,6 +477,7 @@ componentTest('emoji', {
|
||||||
test(assert) {
|
test(assert) {
|
||||||
assert.equal($('.emoji-modal').length, 0);
|
assert.equal($('.emoji-modal').length, 0);
|
||||||
|
|
||||||
|
jumpEnd(this.$('textarea.d-editor-input')[0]);
|
||||||
click('button.emoji');
|
click('button.emoji');
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.equal($('.emoji-modal').length, 1);
|
assert.equal($('.emoji-modal').length, 1);
|
||||||
|
|
Loading…
Reference in New Issue