node tests: Directly test how we add/remove rtl class.

This commit is contained in:
Steve Howell 2021-03-05 15:35:06 +00:00 committed by Steve Howell
parent ea2e5de54f
commit 886e419731
1 changed files with 20 additions and 0 deletions

View File

@ -4,6 +4,7 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const rtl = zrequire("rtl");
@ -126,3 +127,22 @@ run_test("get_direction", () => {
"ltr",
);
});
run_test("set_rtl_class_for_textarea rtl", () => {
const textarea = $.create("some-textarea");
assert(!textarea.hasClass("rtl"));
const text = "```quote\nمرحبا";
textarea.val(text);
rtl.set_rtl_class_for_textarea(textarea);
assert(textarea.hasClass("rtl"));
});
run_test("set_rtl_class_for_textarea ltr", () => {
const textarea = $.create("some-textarea");
textarea.addClass("rtl");
assert(textarea.hasClass("rtl"));
const text = "```quote\nEnglish text";
textarea.val(text);
rtl.set_rtl_class_for_textarea(textarea);
assert(!textarea.hasClass("rtl"));
});