mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
36 lines
829 B
JavaScript
Executable File
36 lines
829 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();
|
|
});
|
|
});
|