|
1 | | -describe('link-in-text-block-matches', function () { |
| 1 | +describe('link-in-text-block-matches', () => { |
2 | 2 | 'use strict'; |
3 | 3 |
|
4 | | - var fixture = document.getElementById('fixture'); |
5 | | - var fixtureSetup = axe.testUtils.fixtureSetup; |
6 | | - var rule; |
| 4 | + const { fixtureSetup } = axe.testUtils; |
| 5 | + const rule = axe.utils.getRule('link-in-text-block'); |
7 | 6 |
|
8 | | - beforeEach(function () { |
9 | | - rule = axe.utils.getRule('link-in-text-block'); |
10 | | - }); |
11 | | - |
12 | | - afterEach(function () { |
13 | | - fixture.innerHTML = ''; |
14 | | - }); |
15 | | - |
16 | | - it('should return true if link is in text block', function () { |
| 7 | + it('should return true if link is in text block', () => { |
17 | 8 | fixtureSetup( |
18 | 9 | '<p>Some paragraph with text <a id="target" href="#">world</a></p>' |
19 | 10 | ); |
20 | | - var node = document.getElementById('target'); |
| 11 | + const node = document.getElementById('target'); |
21 | 12 | assert.isTrue(rule.matches(node)); |
22 | 13 | }); |
23 | 14 |
|
24 | | - it('should return false if element has a non-link role', function () { |
| 15 | + it('should return false if element has a non-link role', () => { |
25 | 16 | fixtureSetup( |
26 | 17 | '<p>Some paragraph with text <a id="target" href="#" role="button">hello</a></p>' |
27 | 18 | ); |
28 | | - var node = document.getElementById('target'); |
| 19 | + const node = document.getElementById('target'); |
29 | 20 | assert.isFalse(rule.matches(node)); |
30 | 21 | }); |
31 | 22 |
|
32 | | - it('should should return false if element does not have text', function () { |
| 23 | + it('should should return false if element does not have text', () => { |
33 | 24 | fixtureSetup( |
34 | 25 | '<p>Some paragraph with text <a id="target" href="#"></a></p>' |
35 | 26 | ); |
36 | | - var node = document.getElementById('target'); |
| 27 | + const node = document.getElementById('target'); |
| 28 | + assert.isFalse(rule.matches(node)); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should return false if element has <style>', () => { |
| 32 | + fixtureSetup(` |
| 33 | + <p>Some paragraph with text |
| 34 | + <a id="target" href="#"> |
| 35 | + <style>a { color: #333 }</style> |
| 36 | + </a> |
| 37 | + </p> |
| 38 | + `); |
| 39 | + const node = document.getElementById('target'); |
| 40 | + assert.isFalse(rule.matches(node)); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should return false if element has <script>', () => { |
| 44 | + fixtureSetup(` |
| 45 | + <p>Some paragraph with text |
| 46 | + <a id="target" href="#"> |
| 47 | + <script>console.log('foo')</script> |
| 48 | + </a> |
| 49 | + </p> |
| 50 | + `); |
| 51 | + const node = document.getElementById('target'); |
37 | 52 | assert.isFalse(rule.matches(node)); |
38 | 53 | }); |
39 | 54 |
|
40 | | - it('should return false if element is hidden', function () { |
| 55 | + it('should return false if element is hidden', () => { |
41 | 56 | fixtureSetup( |
42 | 57 | '<p>Some paragraph with text <a id="target" href="#"" style="display: none">hello</a></p>' |
43 | 58 | ); |
44 | | - var node = document.getElementById('target'); |
| 59 | + const node = document.getElementById('target'); |
45 | 60 | assert.isFalse(rule.matches(node)); |
46 | 61 | }); |
47 | 62 |
|
48 | | - it('should return false if link is not in text block', function () { |
| 63 | + it('should return false if link is not in text block', () => { |
49 | 64 | fixtureSetup('<a id="target" href="#">hello</a>'); |
50 | | - var node = document.getElementById('target'); |
| 65 | + const node = document.getElementById('target'); |
51 | 66 | assert.isFalse(rule.matches(node)); |
52 | 67 | }); |
53 | 68 |
|
54 | | - it('should return false if link is only text in block', function () { |
| 69 | + it('should return false if link is only text in block', () => { |
55 | 70 | fixtureSetup('<p><a id="target" href="#">world</a></p>'); |
56 | | - var node = document.getElementById('target'); |
| 71 | + const node = document.getElementById('target'); |
57 | 72 | assert.isFalse(rule.matches(node)); |
58 | 73 | }); |
59 | 74 |
|
60 | | - it('should return false if link is display block', function () { |
| 75 | + it('should return false if link is display block', () => { |
61 | 76 | fixtureSetup( |
62 | 77 | '<p>Some paragraph with text <a id="target" href="#" style="display: block">world</a></p>' |
63 | 78 | ); |
64 | | - var node = document.getElementById('target'); |
| 79 | + const node = document.getElementById('target'); |
65 | 80 | assert.isFalse(rule.matches(node)); |
66 | 81 | }); |
67 | 82 | }); |
0 commit comments