source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isNonLiteralProperty-test.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import test from 'tape';
2
3import isNonLiteralProperty from '../../../src/util/isNonLiteralProperty';
4import IdentifierMock from '../../../__mocks__/IdentifierMock';
5import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
6import JSXSpreadAttributeMock from '../../../__mocks__/JSXSpreadAttributeMock';
7import JSXTextMock from '../../../__mocks__/JSXTextMock';
8import LiteralMock from '../../../__mocks__/LiteralMock';
9
10const theProp = 'theProp';
11
12const spread = JSXSpreadAttributeMock('theSpread');
13
14test('isNonLiteralProperty', (t) => {
15 t.equal(
16 isNonLiteralProperty([], theProp),
17 false,
18 'does not identify them as non-literal role elements',
19 );
20
21 t.equal(
22 isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
23 false,
24 'does not identify elements with a literal property as non-literal role elements without spread operator',
25 );
26
27 t.equal(
28 isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp),
29 false,
30 'does not identify elements with a literal property as non-literal role elements with spread operator',
31 );
32
33 t.equal(
34 isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp),
35 false,
36 'identifies elements with a JSXText property as non-literal role elements',
37 );
38
39 t.equal(
40 isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('undefined'))], theProp),
41 false,
42 'does not identify elements with a property of undefined as non-literal role elements',
43 );
44
45 t.equal(
46 isNonLiteralProperty([JSXAttributeMock(theProp, IdentifierMock('theIdentifier'))], theProp),
47 true,
48 'identifies elements with an expression property as non-literal role elements',
49 );
50
51 t.end();
52});
Note: See TracBrowser for help on using the repository browser.