mirror of
https://gitlab.silvrtree.co.uk/martind2000/frontexpress.git
synced 2025-01-11 22:45:08 +00:00
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
/*eslint-env mocha*/
|
|
import {assert} from 'chai';
|
|
import Settings from '../lib/settings';
|
|
|
|
describe('Settings', () => {
|
|
const settings = new Settings();
|
|
|
|
describe('http GET method transformer', () => {
|
|
it('simple uri', () => {
|
|
const uriFn = settings.get('http GET transformer').uri;
|
|
const dataFn = settings.get('http GET transformer').data;
|
|
|
|
assert(uriFn({uri: '/route', data:{a:'b', c:'d'}}) === '/route?a=b&c=d');
|
|
assert(dataFn({uri: '/route', data:{a:'b', c:'d'}}) === undefined);
|
|
});
|
|
|
|
it('uri with query string', () => {
|
|
const uriFn = settings.get('http GET transformer').uri;
|
|
const dataFn = settings.get('http GET transformer').data;
|
|
|
|
assert(uriFn({uri: '/route?x=y&z=a', data:{a:'b', c:'d'}}) === '/route?x=y&z=a&a=b&c=d');
|
|
assert(dataFn({uri: '/route?x=y&z=a', data:{a:'b', c:'d'}}) === undefined);
|
|
});
|
|
|
|
it('uri with query string and anchor', () => {
|
|
const uriFn = settings.get('http GET transformer').uri;
|
|
const dataFn = settings.get('http GET transformer').data;
|
|
|
|
assert(uriFn({uri: '/route?x=y&z=a#anchor1', data:{a:'b', c:'d'}}) === '/route?x=y&z=a&a=b&c=d#anchor1');
|
|
assert(dataFn({uri: '/route?x=y&z=a#anchor1', data:{a:'b', c:'d'}}) === undefined);
|
|
});
|
|
});
|
|
}); |