Skip to content

Commit

Permalink
Adds storage, deviceId, and sessionId tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Rogers <[email protected]>
  • Loading branch information
chrissrogers committed Apr 27, 2018
1 parent 84ac89e commit 2ebe151
Show file tree
Hide file tree
Showing 12 changed files with 348 additions and 229 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = "https://registry.npmjs.org/"
9 changes: 7 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ var staticConfig = {
colors: true,
autoWatch: true,
browsers: [
'PhantomJS'
// 'ChromeDebug'
// 'PhantomJS'
'ChromeDebug'
// 'FirefoxDebug'
// 'IE11 - Win7'
],
singleRun: true,
Expand All @@ -25,6 +26,10 @@ var staticConfig = {
ChromeDebug: {
base: 'Chrome',
flags: ['--auto-open-devtools-for-tabs']
},
FirefoxDebug: {
base: 'Firefox',
flags: ['-devtools']
}
},
client: {
Expand Down
12 changes: 10 additions & 2 deletions lib/recurly/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export class Request {
return this.recurly.isParent ? this.recurly.version : this.recurly.config.parentVersion;
}

get deviceId () {
return this.recurly.deviceId;
}

get sessionId () {
return this.recurly.sessionId;
}

get shouldUseXHR () {
return !!this.recurly.config.cors;
}
Expand Down Expand Up @@ -76,10 +84,10 @@ export class Request {
throw errors('not-configured');
}

const { version, key, timeout } = this;
const { version, key, deviceId, sessionId, timeout } = this;
const url = this.recurly.url(route);

data = deepAssign({}, data, { version, key });
data = deepAssign({}, data, { version, key, deviceId, sessionId });

if (this.shouldUseXHR) {
return this.xhr({ method, url, data, done, timeout });
Expand Down
4 changes: 2 additions & 2 deletions lib/util/web-storage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NAMESPACE = '__recurly__';
export const NAMESPACE = '__recurly__';

/**
* Fetches a value from web storage, optionally setting its value
Expand All @@ -10,7 +10,7 @@ const NAMESPACE = '__recurly__';
* @return {Mixed} item value
*/
export function storage ({ scope = 'local', key, otherwise }) {
const store = scope === 'session' ? global.sessionStorage : global.localStorage;
const store = scope === 'session' ? window.sessionStorage : window.localStorage;
let qualifiedKey = `${NAMESPACE}.${key}`;
let value = store.getItem(qualifiedKey);

Expand Down
Loading

0 comments on commit 2ebe151

Please sign in to comment.