Skip to content

Commit bdf2409

Browse files
committed
fix: passing through constructorMixin in configure()
1 parent ca723f7 commit bdf2409

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

configure/request-next.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ module.exports = function (options) {
3535

3636

3737
var plumbing = core({
38-
PromiseImpl: options.PromiseImpl
38+
PromiseImpl: options.PromiseImpl,
39+
constructorMixin: options.constructorMixin
3940
});
4041

4142
return function (requestOptions) {

configure/request2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module.exports = function (options) {
2424

2525

2626
var plumbing = core({
27-
PromiseImpl: options.PromiseImpl
27+
PromiseImpl: options.PromiseImpl,
28+
constructorMixin: options.constructorMixin
2829
});
2930

3031

test/spec/request-next.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,34 @@ describe('Promise-Core for Request@next', function () {
9292

9393
});
9494

95+
it('should forward the constructorMixin', function () {
96+
97+
var mixinCalled = false; // eslint-disable-line no-unused-vars
98+
99+
var request = api({
100+
type: 'basic',
101+
define: {
102+
request: configure({
103+
client: client,
104+
PromiseImpl: Bluebird,
105+
expose: [
106+
'then',
107+
'catch'
108+
],
109+
constructorMixin: function () {
110+
mixinCalled = true;
111+
}
112+
})
113+
}
114+
});
115+
116+
return request('http://localhost:4000') // not started yet so expecting ECONNREFUSED
117+
.catch(function () {
118+
expect(mixinCalled).to.eql(true);
119+
});
120+
121+
});
122+
95123
});
96124

97125
/**

test/spec/request2.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,30 @@ describe('Promise-Core for Request@2', function () {
9292

9393
});
9494

95+
it('should forward the constructorMixin', function () {
96+
97+
var mixinCalled = false; // eslint-disable-line no-unused-vars
98+
99+
var request = stealthyRequire(require.cache, function () {
100+
return require('request');
101+
});
102+
103+
configure({
104+
request: request,
105+
expose: ['then', 'catch'],
106+
PromiseImpl: Bluebird,
107+
constructorMixin: function () {
108+
mixinCalled = true;
109+
}
110+
});
111+
112+
return request('http://localhost:4000') // not started yet so expecting ECONNREFUSED
113+
.catch(function () {
114+
expect(mixinCalled).to.eql(true);
115+
});
116+
117+
});
118+
95119
});
96120

97121
/**

0 commit comments

Comments
 (0)