Permalink
Cannot retrieve contributors at this time
44 lines (41 sloc)
2.08 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/isNonLiteralProperty-test.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import expect from 'expect'; | |
import isNonLiteralProperty from '../../../src/util/isNonLiteralProperty'; | |
import IdentifierMock from '../../../__mocks__/IdentifierMock'; | |
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock'; | |
import JSXSpreadAttributeMock from '../../../__mocks__/JSXSpreadAttributeMock'; | |
import JSXTextMock from '../../../__mocks__/JSXTextMock'; | |
import LiteralMock from '../../../__mocks__/LiteralMock'; | |
const theProp = 'theProp'; | |
const spread = JSXSpreadAttributeMock('theSpread'); | |
describe('isNonLiteralProperty', () => { | |
describe('elements without the property', () => { | |
it('should not identify them as non-literal role elements', () => { | |
expect(isNonLiteralProperty([], theProp)).toBe(false); | |
}); | |
}); | |
describe('elements with a literal property', () => { | |
it('should not identify them as non-literal role elements without spread operator', () => { | |
expect(isNonLiteralProperty([JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false); | |
}); | |
it('should not identify them as non-literal role elements with spread operator', () => { | |
expect(isNonLiteralProperty([spread, JSXAttributeMock(theProp, LiteralMock('theRole'))], theProp)).toBe(false); | |
}); | |
}); | |
describe('elements with a JSXText property', () => { | |
it('should not identify them as non-literal role elements', () => { | |
expect(isNonLiteralProperty([JSXAttributeMock(theProp, JSXTextMock('theRole'))], theProp)).toBe(false); | |
}); | |
}); | |
describe('elements with a property of undefined', () => { | |
it('should not identify them as non-literal role elements', () => { | |
const undefinedExpression = IdentifierMock('undefined'); | |
expect(isNonLiteralProperty([JSXAttributeMock(theProp, undefinedExpression)], theProp)).toBe(false); | |
}); | |
}); | |
describe('elements with a expression property', () => { | |
it('should identify them as non-literal role elements', () => { | |
const identifierExpression = IdentifierMock('theIdentifier'); | |
expect(isNonLiteralProperty([JSXAttributeMock(theProp, identifierExpression)], theProp)).toBe(true); | |
}); | |
}); | |
}); |