@tinymce/beehive-flow
Version:
A CLI tool implementing the beehive flow git branching process
30 lines (26 loc) • 915 B
text/typescript
import { describe, it } from 'mocha';
import { assert } from 'chai';
import fc from 'fast-check';
import * as ObjUtils from '../../../main/ts/utils/ObjUtils';
describe('ObjUtils', () => {
describe('fromPairs', () => {
it('returns empty object for empty array', () => {
assert.deepEqual(ObjUtils.fromPairs([]), {});
});
it('returns single-key object for single-element array', () => {
fc.assert(fc.property(fc.string(), fc.nat(), (k, v) => {
if (k === '__proto__') {
assert.deepEqual(ObjUtils.fromPairs([[ k, v ]]), {});
} else {
assert.deepEqual(ObjUtils.fromPairs([[ k, v ]]), { [k]: v });
}
}));
});
it('returns correct objects for larger arrays', () => {
assert.deepEqual(
ObjUtils.fromPairs([[ 'a', 'zingo' ], [ 'hasOwnProperty', '*' ]]),
{ a: 'zingo', hasOwnProperty: '*' }
);
});
});
});