Permalink
Cannot retrieve contributors at this time
115 lines (114 sloc)
3.65 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/attributesComparator-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 attributesComparator from '../../../src/util/attributesComparator'; | |
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock'; | |
import JSXElementMock from '../../../__mocks__/JSXElementMock'; | |
describe('attributesComparator', () => { | |
describe('base attributes', () => { | |
let baseAttributes; | |
let attributes; | |
describe('are undefined', () => { | |
describe('and attributes are undefined', () => { | |
it('should return true', () => { | |
expect(attributesComparator()).toBe(true); | |
}); | |
}); | |
}); | |
describe('are empty', () => { | |
beforeEach(() => { | |
baseAttributes = []; | |
}); | |
describe('and attributes', () => { | |
describe('are empty', () => { | |
attributes = []; | |
it('should return true', () => { | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(true); | |
}); | |
}); | |
describe('have values', () => { | |
attributes = [ | |
JSXAttributeMock('foo', 0), | |
JSXAttributeMock('bar', 'baz'), | |
]; | |
it('should return true', () => { | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(true); | |
}); | |
}); | |
}); | |
}); | |
describe('have values', () => { | |
beforeEach(() => { | |
baseAttributes = [ | |
{ | |
name: 'biz', | |
value: 1, | |
}, { | |
name: 'fizz', | |
value: 'pop', | |
}, { | |
name: 'fuzz', | |
value: 'lolz', | |
}, | |
]; | |
}); | |
describe('and attributes', () => { | |
describe('are empty', () => { | |
attributes = []; | |
it('should return false', () => { | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(false); | |
}); | |
}); | |
describe('have values', () => { | |
describe('and the values are the different', () => { | |
it('should return false', () => { | |
attributes = [ | |
JSXElementMock(), | |
JSXAttributeMock('biz', 2), | |
JSXAttributeMock('ziff', 'opo'), | |
JSXAttributeMock('far', 'lolz'), | |
]; | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(false); | |
}); | |
}); | |
describe('and the values are a subset', () => { | |
it('should return true', () => { | |
attributes = [ | |
JSXAttributeMock('biz', 1), | |
JSXAttributeMock('fizz', 'pop'), | |
JSXAttributeMock('goo', 'gazz'), | |
]; | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(false); | |
}); | |
}); | |
describe('and the values are the same', () => { | |
it('should return true', () => { | |
attributes = [ | |
JSXAttributeMock('biz', 1), | |
JSXAttributeMock('fizz', 'pop'), | |
JSXAttributeMock('fuzz', 'lolz'), | |
]; | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(true); | |
}); | |
}); | |
describe('and the values are a superset', () => { | |
it('should return true', () => { | |
attributes = [ | |
JSXAttributeMock('biz', 1), | |
JSXAttributeMock('fizz', 'pop'), | |
JSXAttributeMock('fuzz', 'lolz'), | |
JSXAttributeMock('dar', 'tee'), | |
]; | |
expect(attributesComparator(baseAttributes, attributes)) | |
.toBe(true); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); |