UNPKG

chance-object

Version:

A Chance.js mixin to generate objects.

39 lines (28 loc) 766 B
const Chance = require('chance'); const object = require('./index'); describe('index.js', () => { const chance = new Chance(); let word; beforeEach(() => { word = chance.word(); spyOn(Chance.prototype, 'word').and.returnValue(word); chance.mixin({ object }); }); test('should return random object', () => { const result = chance.object(); expect(result).toEqual({ [word]: word }); }); test('should return random object along with specified keys / values', () => { const result = chance.object({ key: 'value' }); expect(result).toEqual({ key: 'value', [word]: word }); }); });