html-utils.spec.ts
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
HtmlUtils
} from "./html-utils";
describe("HtmlUtils", () => {
let element: ng.IAugmentedJQuery;
beforeEach(inject(($compile: ng.ICompileService, $rootScope: ng.IRootScopeService) => {
element = $compile("<a></a>")($rootScope);
}));
it("removes a css class matching some prefix from an HTML Element", () => {
element.addClass("noosfero-class1");
element.addClass("noosfero-class2");
element.addClass("another-class");
HtmlUtils.removeCssClassByPrefix(element[0], "noosfero-");
// we expect classes prefixed with 'noosfero-' to be removed
expect(element[0].classList).not.toContain("noosfero-class1");
expect(element[0].classList).not.toContain("noosfero-class2");
// class not prefixed with 'noosfero-' should be there
expect(element[0].classList).toContain("another-class");
});
it("removes a css class matching some suffix from an HTML Element", () => {
element.addClass("class-1-noosfero");
element.addClass("class-2-noosfero");
element.addClass("another-class");
HtmlUtils.removeCssClassBySuffix(element[0], "-noosfero");
// we expect classes prefixed with 'noosfero-' to be removed
expect(element[0].classList).not.toContain("class-1-noosfero");
expect(element[0].classList).not.toContain("class-2-noosfero");
// class not suffixed with '-noosfero' should be there
expect(element[0].classList).toContain("another-class");
});
});