Skip to content

Commit

Permalink
fix: Fix regression in ms-prefixed PlayReady license request callback…
Browse files Browse the repository at this point in the history
…s caused by #81 (#83)
  • Loading branch information
misteroneill committed May 1, 2019
1 parent 6ac97bb commit b52ba35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/ms-prefixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const addKeyToSession = (options, session, event, eventBus) => {
playreadyOptions.url = event.destinationURL;
}

requestPlayreadyLicense(playreadyOptions, event.message.buffer, options, (err, response) => {
requestPlayreadyLicense(playreadyOptions, event.message.buffer, options, (err, responseBody) => {
if (eventBus) {
eventBus.trigger('licenserequestattempted');
}
Expand All @@ -53,7 +53,7 @@ export const addKeyToSession = (options, session, event, eventBus) => {
return;
}

session.update(new Uint8Array(response.body));
session.update(new Uint8Array(responseBody));
});
};

Expand Down
14 changes: 7 additions & 7 deletions test/ms-prefixed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ QUnit.test('calls getKey when provided on key message', function(assert) {
assert.equal(this.session.keys[0], 'a key', 'added correct key to session');

getKeyCallback = (callback) => {
callback('an error', {}, 'an errored key');
callback('an error', 'an errored key');
};

this.session.trigger({
Expand Down Expand Up @@ -253,14 +253,14 @@ QUnit.test('makes request when nothing provided on key message', function(assert
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', {}, response);
xhrCalls[0].callback('an error', response, response.body);

assert.equal(errorMessage,
'Unable to request key from url: destination-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, {}, response);
xhrCalls[0].callback(null, response, response.body);

assert.equal(this.session.keys.length, 1, 'key added to session');
assert.deepEqual(this.session.keys[0],
Expand Down Expand Up @@ -372,14 +372,14 @@ QUnit.test('makes request with provided url string on key message', function(ass
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', {}, response);
xhrCalls[0].callback('an error', response, response.body);

assert.equal(errorMessage,
'Unable to request key from url: provided-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, {}, response);
xhrCalls[0].callback(null, response, response.body);

assert.equal(this.session.keys.length, 1, 'key added to session');
assert.deepEqual(this.session.keys[0],
Expand Down Expand Up @@ -456,15 +456,15 @@ QUnit.test('makes request with provided url on key message', function(assert) {
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', {}, response);
xhrCalls[0].callback('an error', response, response.body);

assert.equal(callCounts.licenseRequestAttempts, 1, 'license request event triggered');
assert.equal(errorMessage,
'Unable to request key from url: provided-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, {}, response);
xhrCalls[0].callback(null, response, response.body);

assert.equal(callCounts.licenseRequestAttempts, 2,
'second license request event triggered');
Expand Down

0 comments on commit b52ba35

Please sign in to comment.