|
1 | | -(function() { |
2 | | - var colorPicker; |
3 | | - var element; |
4 | | - |
5 | | - describe("colorpalette", function() { |
6 | | - beforeEach(function() { |
7 | | - element = $("<div>").kendoColorPalette(); |
8 | | - colorPicker = element.data("kendoColorPalette"); |
9 | | - }); |
10 | | - afterEach(function() { |
11 | | - colorPicker.destroy(); |
12 | | - }); |
13 | | - |
14 | | - it("renders aria-label for each color", function() { |
15 | | - element.find(".k-item").each(function() { |
16 | | - var label = $(this).attr("aria-label"); |
17 | | - assert.isOk(label, "aria-label defined on cells"); // label defined |
18 | | - var bg = $(this); |
19 | | - var color = kendo.parseColor(label); |
20 | | - bg = kendo.parseColor(bg.css("background-color")); |
21 | | - assert.isOk(color && bg && color.equals(bg), "aria-label is same as background color"); |
22 | | - }); |
23 | | - }); |
24 | | - |
25 | | - it("maintains aria-selected attribute consistent with selection", function() { |
26 | | - var items = element.find(".k-item"); |
27 | | - |
28 | | - assert.equal(element.find("[aria-selected=true]").length, 0); |
29 | | - |
30 | | - items.last().click(); |
31 | | - |
32 | | - var selected = element.find("[aria-selected=true]"); |
33 | | - assert.isOk(selected[0] === items.last()[0]); |
34 | | - assert.equal(selected.length, 1); |
35 | | - }); |
36 | | - |
37 | | - it("sets aria-activedescendant based on selection", function() { |
38 | | - var lastColor = element.find(".k-item").last(); |
39 | | - |
40 | | - lastColor.click(); |
41 | | - |
42 | | - assert.isOk(element.is("[aria-activedescendant]")); |
43 | | - assert.equal(element.attr("aria-activedescendant"), lastColor.attr("id")); |
44 | | - }); |
45 | | - |
46 | | - it("renders role='row' for each tr", function() { |
47 | | - var rows = element.find("tr"); |
48 | | - |
49 | | - assert.equal(rows.filter("[role=row]").length, rows.length); |
50 | | - }); |
51 | | - |
52 | | - it("renders role='gridcell' for each td", function() { |
53 | | - var cells = element.find("td"); |
54 | | - |
55 | | - assert.equal(cells.filter("[role=gridcell]").length, cells.length); |
56 | | - }); |
57 | | - }); |
58 | | - |
59 | | - describe("color picker", function() { |
60 | | - beforeEach(function() { |
61 | | - element = $("<input/>").kendoColorPicker(); |
62 | | - colorPicker = element.data("kendoColorPicker"); |
63 | | - }); |
64 | | - afterEach(function() { |
65 | | - colorPicker.destroy(); |
66 | | - }); |
67 | | - |
68 | | - it("renders role='textbox' to the wrapper", function() { |
69 | | - var wrapper = colorPicker.wrapper; |
70 | | - |
71 | | - assert.equal(wrapper.attr("role"), "textbox"); |
72 | | - }); |
73 | | - |
74 | | - it("renders aria-haspopup='true' to the wrapper", function() { |
75 | | - var wrapper = colorPicker.wrapper; |
76 | | - |
77 | | - assert.equal(wrapper.attr("aria-haspopup"), "true"); |
78 | | - }); |
79 | | - |
80 | | - it("render popup with id", function() { |
81 | | - colorPicker.open(); |
82 | | - |
83 | | - var popup = colorPicker._popup.element; |
84 | | - |
85 | | - assert.isOk(popup.attr("id")); |
86 | | - }); |
87 | | - |
88 | | - it("render aria-owns to the wrapper", function() { |
89 | | - colorPicker.open(); |
90 | | - |
91 | | - assert.equal(colorPicker.wrapper.attr("aria-owns"), colorPicker._popup.element.attr("id")); |
92 | | - }); |
93 | | - |
94 | | - it("renders aria-disabled=false", function() { |
95 | | - assert.equal(colorPicker.wrapper.attr("aria-disabled"), "false"); |
96 | | - }); |
97 | | - |
98 | | - it("renders aria-disabled=true", function() { |
99 | | - colorPicker.enable(false); |
100 | | - |
101 | | - assert.equal(colorPicker.wrapper.attr("aria-disabled"), "true"); |
102 | | - assert.isOk(!colorPicker.wrapper.attr("disabled")); |
103 | | - }); |
104 | | - |
105 | | - it("renders aria-label to the wrapper", function() { |
106 | | - colorPicker.value("#f9d9ab"); |
107 | | - |
108 | | - assert.isOk(colorPicker.wrapper.attr("aria-label").indexOf("#f9d9ab") !== -1); |
109 | | - }); |
110 | | - }); |
111 | | - |
112 | | - describe("flatcolorpicker", function() { |
113 | | - beforeEach(function() { |
114 | | - element = $("<div>").kendoFlatColorPicker({ |
115 | | - preview: true |
116 | | - }); |
117 | | - colorPicker = element.data("kendoFlatColorPicker"); |
118 | | - }); |
119 | | - afterEach(function() { |
120 | | - colorPicker.destroy(); |
121 | | - }); |
122 | | - |
123 | | - it("renders aria-label to the slider", function() { |
124 | | - var ariaLabel = colorPicker.wrapper.find(".k-hue-slider input").attr("aria-label"); |
125 | | - assert.isOk(ariaLabel === "hue saturation"); |
126 | | - }); |
127 | | - |
128 | | - it("renders title to the preview input", function() { |
129 | | - var ariaLabel = colorPicker.wrapper.find(".k-color-value").attr("title"); |
130 | | - assert.isOk(ariaLabel === "Color Hexadecimal Code"); |
131 | | - }); |
132 | | - |
133 | | - }); |
134 | | -}()); |
| 1 | +(function() { |
| 2 | + var colorPicker; |
| 3 | + var element; |
| 4 | + |
| 5 | + describe("colorpalette", function() { |
| 6 | + beforeEach(function() { |
| 7 | + element = $("<div>").appendTo(Mocha.fixture).kendoColorPalette(); |
| 8 | + colorPicker = element.data("kendoColorPalette"); |
| 9 | + }); |
| 10 | + afterEach(function() { |
| 11 | + colorPicker.destroy(); |
| 12 | + }); |
| 13 | + |
| 14 | + it("renders aria-label for each color", function() { |
| 15 | + element.find(".k-item").each(function() { |
| 16 | + var label = $(this).attr("aria-label"); |
| 17 | + assert.isOk(label, "aria-label defined on cells"); // label defined |
| 18 | + var bg = $(this); |
| 19 | + var color = kendo.parseColor(label); |
| 20 | + bg = kendo.parseColor(bg.css("background-color")); |
| 21 | + assert.isOk(color && bg && color.equals(bg), "aria-label is same as background color"); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
| 25 | + it("maintains aria-selected attribute consistent with selection", function() { |
| 26 | + var items = element.find(".k-item"); |
| 27 | + |
| 28 | + assert.equal(element.find("[aria-selected=true]").length, 0); |
| 29 | + |
| 30 | + items.last().click(); |
| 31 | + |
| 32 | + var selected = element.find("[aria-selected=true]"); |
| 33 | + assert.isOk(selected[0] === items.last()[0]); |
| 34 | + assert.equal(selected.length, 1); |
| 35 | + }); |
| 36 | + |
| 37 | + it("sets aria-activedescendant based on selection", function() { |
| 38 | + var lastColor = element.find(".k-item").last(); |
| 39 | + |
| 40 | + lastColor.click(); |
| 41 | + |
| 42 | + assert.isOk(element.is("[aria-activedescendant]")); |
| 43 | + assert.equal(element.attr("aria-activedescendant"), lastColor.attr("id")); |
| 44 | + }); |
| 45 | + |
| 46 | + it("renders role='row' for each tr", function() { |
| 47 | + var rows = element.find("tr"); |
| 48 | + |
| 49 | + assert.equal(rows.filter("[role=row]").length, rows.length); |
| 50 | + }); |
| 51 | + |
| 52 | + it("renders role='gridcell' for each td", function() { |
| 53 | + var cells = element.find("td"); |
| 54 | + |
| 55 | + assert.equal(cells.filter("[role=gridcell]").length, cells.length); |
| 56 | + }); |
| 57 | + |
| 58 | + it("colorpalette is accessible with AXE", function(done) { |
| 59 | + axeRunFixture(done); |
| 60 | + }); |
| 61 | + }); |
| 62 | + |
| 63 | + describe("color picker", function() { |
| 64 | + beforeEach(function() { |
| 65 | + element = $("<input/>").appendTo(Mocha.fixture).kendoColorPicker(); |
| 66 | + colorPicker = element.data("kendoColorPicker"); |
| 67 | + }); |
| 68 | + afterEach(function() { |
| 69 | + colorPicker.destroy(); |
| 70 | + }); |
| 71 | + |
| 72 | + it("renders role='textbox' to the wrapper", function() { |
| 73 | + var wrapper = colorPicker.wrapper; |
| 74 | + |
| 75 | + assert.equal(wrapper.attr("role"), "textbox"); |
| 76 | + }); |
| 77 | + |
| 78 | + it("renders aria-haspopup='true' to the wrapper", function() { |
| 79 | + var wrapper = colorPicker.wrapper; |
| 80 | + |
| 81 | + assert.equal(wrapper.attr("aria-haspopup"), "true"); |
| 82 | + }); |
| 83 | + |
| 84 | + it("render popup with id", function() { |
| 85 | + colorPicker.open(); |
| 86 | + |
| 87 | + var popup = colorPicker._popup.element; |
| 88 | + |
| 89 | + assert.isOk(popup.attr("id")); |
| 90 | + }); |
| 91 | + |
| 92 | + it("render aria-owns to the wrapper", function() { |
| 93 | + colorPicker.open(); |
| 94 | + |
| 95 | + assert.equal(colorPicker.wrapper.attr("aria-owns"), colorPicker._popup.element.attr("id")); |
| 96 | + }); |
| 97 | + |
| 98 | + it("renders aria-disabled=false", function() { |
| 99 | + assert.equal(colorPicker.wrapper.attr("aria-disabled"), "false"); |
| 100 | + }); |
| 101 | + |
| 102 | + it("renders aria-disabled=true", function() { |
| 103 | + colorPicker.enable(false); |
| 104 | + |
| 105 | + assert.equal(colorPicker.wrapper.attr("aria-disabled"), "true"); |
| 106 | + assert.isOk(!colorPicker.wrapper.attr("disabled")); |
| 107 | + }); |
| 108 | + |
| 109 | + it("renders aria-label to the wrapper", function() { |
| 110 | + colorPicker.value("#f9d9ab"); |
| 111 | + |
| 112 | + assert.isOk(colorPicker.wrapper.attr("aria-label").indexOf("#f9d9ab") !== -1); |
| 113 | + }); |
| 114 | + |
| 115 | + it("colorpicker is accessible with AXE", function(done) { |
| 116 | + axeRunFixture(done); |
| 117 | + }); |
| 118 | + |
| 119 | + it("colorpicker popup is accessible with AXE", function(done) { |
| 120 | + colorPicker.open(); |
| 121 | + |
| 122 | + // excluded rule should be removed after fixing the issue in the slider |
| 123 | + axeRun(colorPicker._popup.element, done, ["aria-allowed-role"]); |
| 124 | + }); |
| 125 | + }); |
| 126 | + |
| 127 | + describe("flatcolorpicker", function() { |
| 128 | + beforeEach(function() { |
| 129 | + element = $("<div>").appendTo(Mocha.fixture).kendoFlatColorPicker({ |
| 130 | + preview: true |
| 131 | + }); |
| 132 | + colorPicker = element.data("kendoFlatColorPicker"); |
| 133 | + }); |
| 134 | + afterEach(function() { |
| 135 | + colorPicker.destroy(); |
| 136 | + }); |
| 137 | + |
| 138 | + it("renders aria-label to the slider", function() { |
| 139 | + var ariaLabel = colorPicker.wrapper.find(".k-hue-slider input").attr("aria-label"); |
| 140 | + assert.isOk(ariaLabel === "hue saturation"); |
| 141 | + }); |
| 142 | + |
| 143 | + it("renders aria-label to the preview input", function() { |
| 144 | + var ariaLabel = colorPicker.wrapper.find(".k-color-value").attr("aria-label"); |
| 145 | + assert.isOk(ariaLabel === "Color Hexadecimal Code"); |
| 146 | + }); |
| 147 | + |
| 148 | + it("flatcolorpicker is accessible with AXE", function(done) { |
| 149 | + // excluded rule should be removed after fixing the issue in the slider |
| 150 | + axeRunFixture(done, ["aria-allowed-role"]); |
| 151 | + }); |
| 152 | + }); |
| 153 | +}()); |
0 commit comments