From 886e4197319c122d5d4167e39a76f431c28cbc3a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 5 Mar 2021 15:35:06 +0000 Subject: [PATCH] node tests: Directly test how we add/remove rtl class. --- frontend_tests/node_tests/rtl.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend_tests/node_tests/rtl.js b/frontend_tests/node_tests/rtl.js index 5afa936ed9..245dda0130 100644 --- a/frontend_tests/node_tests/rtl.js +++ b/frontend_tests/node_tests/rtl.js @@ -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")); +});