-
-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows us to: - drop all the jest mocks - no longer be stuck on an EOL version nor be forced to raise the engines.node threshold - run tests 4x faster: jest takes 27.365s, tape takes 7.086s
- Loading branch information
Showing
40 changed files
with
1,723 additions
and
1,315 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,91 @@ | ||
import expect from 'expect'; | ||
import test from 'tape'; | ||
|
||
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); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
test('attributesComparator', (t) => { | ||
t.equal( | ||
attributesComparator(), | ||
true, | ||
'baseAttributes are undefined and attributes are undefined -> true', | ||
); | ||
|
||
t.equal( | ||
attributesComparator([], []), | ||
true, | ||
'baseAttributes are empty and attributes are empty -> true', | ||
); | ||
|
||
t.equal( | ||
attributesComparator([], [ | ||
JSXAttributeMock('foo', 0), | ||
JSXAttributeMock('bar', 'baz'), | ||
]), | ||
true, | ||
'baseAttributes are empty and attributes have values -> true', | ||
); | ||
|
||
const baseAttributes = [ | ||
{ | ||
name: 'biz', | ||
value: 1, | ||
}, { | ||
name: 'fizz', | ||
value: 'pop', | ||
}, { | ||
name: 'fuzz', | ||
value: 'lolz', | ||
}, | ||
]; | ||
|
||
t.equal( | ||
attributesComparator(baseAttributes, []), | ||
false, | ||
'baseAttributes have values and attributes are empty -> false', | ||
); | ||
|
||
t.equal( | ||
attributesComparator(baseAttributes, [ | ||
JSXElementMock(), | ||
JSXAttributeMock('biz', 2), | ||
JSXAttributeMock('ziff', 'opo'), | ||
JSXAttributeMock('far', 'lolz'), | ||
]), | ||
false, | ||
'baseAttributes have values and attributes have values, and the values are different -> false', | ||
); | ||
|
||
t.equal( | ||
attributesComparator(baseAttributes, [ | ||
JSXAttributeMock('biz', 1), | ||
JSXAttributeMock('fizz', 'pop'), | ||
JSXAttributeMock('goo', 'gazz'), | ||
]), | ||
false, | ||
'baseAttributes have values and attributes have values, and the values are a subset -> false', | ||
); | ||
|
||
t.equal( | ||
attributesComparator(baseAttributes, [ | ||
JSXAttributeMock('biz', 1), | ||
JSXAttributeMock('fizz', 'pop'), | ||
JSXAttributeMock('fuzz', 'lolz'), | ||
]), | ||
true, | ||
'baseAttributes have values and attributes have values, and the values are the same -> true', | ||
); | ||
|
||
t.equal( | ||
attributesComparator(baseAttributes, [ | ||
JSXAttributeMock('biz', 1), | ||
JSXAttributeMock('fizz', 'pop'), | ||
JSXAttributeMock('fuzz', 'lolz'), | ||
JSXAttributeMock('dar', 'tee'), | ||
]), | ||
true, | ||
'baseAttributes have values and attributes have values, and the values are a superset -> true', | ||
); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.