Skip to content

added extra argument to stub method#8

Open
andersgjetting wants to merge 1 commit intomapbox:masterfrom
andersgjetting:patch
Open

added extra argument to stub method#8
andersgjetting wants to merge 1 commit intomapbox:masterfrom
andersgjetting:patch

Conversation

@andersgjetting
Copy link

added extra argument to stub method as some AWS sdk methods take more than 2 arguments e.g waitFor(state, params = {}, callback)

… than 2 arguments e.g waitFor(state, params = {}, callback)
@rclark
Copy link
Contributor

rclark commented Jan 2, 2018

Thanks for this contribution! Could you please add a test that confirms that the functionality works as intended? As an example, you could build a test similar to this one, but stub waitFor and use 3 args:

test('[useCallback] use replacement function', function(assert) {
var getObject = AWS.stub('S3', 'getObject', function(params, callback) {
callback(null, data);
});
app.useCallback(function(err, data) {
assert.ifError(err, 'success');
assert.equal(data, 'hello world');
assert.equal(AWS.S3.callCount, 1, 'one s3 client created');
assert.ok(AWS.S3.calledWithExactly({ region }), 's3 client created for the correct region');
assert.equal(getObject.callCount, 1, 'called s3.getObject once');
assert.ok(getObject.calledWith(expected), 'called s3.getObject with expected params');
AWS.S3.restore();
assert.end();
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants