Skip to content

Commit e385384

Browse files
authored
Merge pull request #1 from mapbox/pomo-proto
add 3 levels of prototypes to Feature.prototype
2 parents dc2f95d + a5deeea commit e385384

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ function stubService(service) {
4646
var client = new Original();
4747

4848
function FakeService(config) { Object.assign(this, new Original(config)); }
49-
FakeService.prototype = Object.assign({}, client.__proto__);
49+
FakeService.prototype = Object.assign(
50+
{},
51+
client.__proto__.__proto__.__proto__,
52+
client.__proto__.__proto__,
53+
client.__proto__
54+
);
5055

5156
var spy = sinon.spy(FakeService);
5257
spy.restore = function() { setService(service, Original); };

test/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,23 @@ test('[multipleMethods] replacement function', function(assert) {
233233
assert.end();
234234
});
235235
});
236+
237+
test('[upload] methods inherited multiple times', function(assert) {
238+
var upload = AWS.stub('S3', 'upload', function(params, callback) {
239+
callback(null, data);
240+
});
241+
242+
app.upload(function(err, data) {
243+
assert.ifError(err, 'success');
244+
assert.equal(data, 'hello world');
245+
246+
assert.equal(AWS.S3.callCount, 1, 'one s3 client created');
247+
assert.ok(AWS.S3.calledWithExactly({ region }), 's3 client created for the correct region');
248+
249+
assert.equal(upload.callCount, 1, 'called s3.upload once');
250+
assert.ok(upload.calledWith(expected), 'called s3.upload with expected params');
251+
252+
AWS.S3.restore();
253+
assert.end();
254+
});
255+
});

test/test-app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var AWS = require('aws-sdk');
22

3-
module.exports = { useCallback, usePromise, streaming, useEvents, multipleMethods };
3+
module.exports = { useCallback, usePromise, streaming, useEvents, multipleMethods, upload };
44

55
function useCallback(callback) {
66
var s3 = new AWS.S3({ region: 'eu-west-1' });
@@ -47,3 +47,11 @@ function multipleMethods(callback) {
4747
.then(function(data) { callback(null, data.Body.toString()); })
4848
.catch(callback);
4949
}
50+
51+
function upload(callback) {
52+
var s3 = new AWS.S3({ region: 'eu-west-1' });
53+
s3.upload({ Bucket: 'bucket', Key: 'key' }, function(err, data) {
54+
if (err) return callback(err);
55+
callback(null, data.Body.toString());
56+
});
57+
}

0 commit comments

Comments
 (0)