Skip to content

Commit

Permalink
package.json: remove qs as dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
pablopalacios committed Sep 20, 2021
1 parent 481a729 commit 6c382b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"pre-commit": "^1.0.0",
"prettier": "^2.3.2",
"puppeteer": "^10.2.0",
"qs": "^6.7.0",
"sinon": "^11.1.1",
"supertest": "^6.0.0",
"webpack": "^5.51.1"
Expand Down
36 changes: 25 additions & 11 deletions tests/unit/libs/fetcher.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

var expect = require('chai').expect;
var mockery = require('mockery');
var qs = require('qs');
var sinon = require('sinon');
var supertest = require('supertest');
var xhr = require('xhr');
Expand All @@ -17,6 +16,7 @@ FakeXMLHttpRequest.onCreate = handleFakeXhr;
xhr.XMLHttpRequest = FakeXMLHttpRequest;

var Fetcher = require('../../../libs/fetcher.client');
var defaultConstructGetUri = require('../../../libs/util/defaultConstructGetUri');
var REST = require('../../../libs/util/http.client');
var testCrud = require('../../util/testCrud');
var defaultOptions = require('../../util/defaultOptions');
Expand Down Expand Up @@ -122,13 +122,8 @@ describe('Client Fetcher', function () {
validateXhr = null;
});
});

describe('CORS', function () {
function constructGetUri(uri, resource, params, config, context) {
params = Object.assign(context, params);
if (config.cors) {
return uri + '/' + resource + '?' + qs.stringify(params);
}
}
before(function () {
validateXhr = function (req) {
if (req.method === 'GET') {
Expand All @@ -149,10 +144,7 @@ describe('Client Fetcher', function () {
testCrud({
params: params,
body: body,
config: {
cors: true,
constructGetUri: constructGetUri,
},
config: { cors: true },
disableNoConfigTests: true,
callback: callback,
resolve: resolve,
Expand Down Expand Up @@ -381,6 +373,28 @@ describe('Client Fetcher', function () {
});
});

describe('Custom constructGetUri', () => {
it('is called correctly', () => {
const fetcher = new Fetcher({});
const constructGetUri = sinon
.stub()
.callsFake(defaultConstructGetUri);

return fetcher
.read('mock_service', { foo: 'bar' }, { constructGetUri })
.then(() => {
sinon.assert.calledOnceWithExactly(
constructGetUri,
'/api',
'mock_service',
{ foo: 'bar' },
{ constructGetUri },
{}
);
});
});
});

describe('Custom request headers', function () {
var VERSION = '1.0.0';

Expand Down

0 comments on commit 6c382b8

Please sign in to comment.