blob: 895a5e90f18251d5eb32885427b67e63edb439fb [file] [log] [blame]
Akron0c4cd222019-07-19 16:33:34 +02001define(['util'], function () {
2 describe('KorAP.util', function () {
3
4 it('should quote', function () {
5 expect('Baum'.quote()).toEqual('"Baum"');
6 expect('B"a"um'.quote()).toEqual('"B\\"a\\"um"');
7 });
8
9 it('should escape regex', function () {
10 expect('aaa/bbb\/ccc'.escapeRegex()).toEqual('aaa\\/bbb\\/ccc');
11 });
12
13 it('should slugify', function () {
14 expect('/korap/test'.slugify()).toEqual('koraptest');
15 expect('korap test'.slugify()).toEqual('korap-test');
16 expect('Korap Test'.slugify()).toEqual('korap-test');
17 });
Akron1cfde272021-06-14 18:32:39 +020018 });
19
20 describe('KorAP.util.initTogllePwdVisibility', function () {
21 it('should toggle', function () {
22 const div = document.createElement('div');
23 let input = div.addE('input');
24 input.setAttribute('type', 'password');
25 input.setAttribute('class', 'show-pwd');
26
27 expect(div.children.length).toEqual(1);
28 initTogglePwdVisibility(div);
29 expect(div.children.length).toEqual(2);
30 expect(div.lastChild.tagName).toEqual("A");
31 expect(div.lastChild.classList.contains("hide")).toBeFalsy();
32 expect(input.getAttribute("type")).toEqual("password");
33
34 div.lastChild.click();
35
36 expect(input.getAttribute("type")).toEqual("text");
37 expect(div.lastChild.classList.contains("hide")).toBeTruthy();
38 });
39 });
Akron0c4cd222019-07-19 16:33:34 +020040});