insomnia/packages/insomnia-httpsnippet/test/reducer.js
Gregory Schier 4901f03041 Add Prettier
2018-06-25 13:42:50 -04:00

39 lines
847 B
JavaScript
Executable File

/* global describe, it */
'use strict';
var reducer = require('../src/helpers/reducer');
require('should');
describe('Reducer', function() {
it('should convert array object pair to key-value object', function(done) {
var query = [
{ name: 'key', value: 'value' },
{ name: 'foo', value: 'bar' }
];
var obj = query.reduce(reducer, {});
obj.should.be.an.Object;
obj.should.eql({ key: 'value', foo: 'bar' });
done();
});
it('should convert multi-dimensional arrays to key=[array] object', function(done) {
var query = [
{ name: 'key', value: 'value' },
{ name: 'foo', value: 'bar1' },
{ name: 'foo', value: 'bar2' }
];
var obj = query.reduce(reducer, {});
obj.should.be.an.Object;
obj.should.eql({ key: 'value', foo: ['bar1', 'bar2'] });
done();
});
});