Refactor code; add tests

This commit is contained in:
scossar
2018-01-29 17:42:19 -08:00
parent 42970e758e
commit 41f1e7430c
7 changed files with 89 additions and 11 deletions

View File

@ -715,6 +715,26 @@ testCase(`list button with line sequence`, function(assert, textarea) {
});
});
componentTest('clicking the toggle-direction button toggles the direction', {
template: '{{d-editor value=value}}',
beforeEach() {
this.siteSettings.support_mixed_text_direction = true;
this.siteSettings.default_locale = "en";
},
test(assert) {
const textarea = this.$('textarea.d-editor-input');
click('button.toggle-direction');
andThen(() => {
assert.equal(textarea.attr('dir'), 'rtl');
});
click('button.toggle-direction');
andThen(() => {
assert.equal(textarea.attr('dir'), 'ltr');
});
}
});
testCase(`doesn't jump to bottom with long text`, function(assert, textarea) {
let longText = 'hello world.';

View File

@ -22,3 +22,27 @@ componentTest("support a placeholder", {
assert.equal(this.$('input').prop('placeholder'), 'placeholder.i18n.key');
}
});
componentTest("sets the dir attribute to ltr for Hebrew text", {
template: `{{text-field value='זהו שם עברי עם מקום עברי'}}`,
beforeEach() {
this.siteSettings.support_mixed_text_direction = true;
},
test(assert) {
assert.equal(this.$('input').attr('dir'), 'rtl');
}
});
componentTest("sets the dir attribute to ltr for English text", {
template: `{{text-field value='This is a ltr title'}}`,
beforeEach() {
this.siteSettings.support_mixed_text_direction = true;
},
test(assert) {
assert.equal(this.$('input').attr('dir'), 'ltr');
}
});