wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

21
test/invert.spec.js Normal file
View File

@@ -0,0 +1,21 @@
import invert from '../src/invert';
describe('invert', () => {
it('should invert an object', () => {
const object = { a: 1, b: 2 };
const actual = invert(object);
expect(actual).toEqual({ 1: 'a', 2: 'b' });
expect(invert(actual)).toEqual({ a: '1', b: '2' });
});
it('should work with values that shadow keys on `Object.prototype`', () => {
const object = { a: 'hasOwnProperty', b: 'constructor' };
expect(invert(object)).toEqual({ hasOwnProperty: 'a', constructor: 'b' });
});
it('should work with an object that has a `length` property', () => {
const object = { 0: 'a', 1: 'b', length: 2 };
expect(invert(object)).toEqual({ a: '0', b: '1', 2: 'length' });
});
});