Skip to content

Commit

Permalink
export function for testing + added test for tenant info
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Dec 1, 2016
1 parent 58ac23e commit 91f5cc3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function extractClientBaseUrlOption(opts, domain) {
}
}

function extractTenantBaseUrlOption(opts, domain) {
export function extractTenantBaseUrlOption(opts, domain) {
if (opts.configurationBaseUrl && typeof opts.configurationBaseUrl === "string") {
return opts.configurationBaseUrl;
}
Expand Down
60 changes: 60 additions & 0 deletions test/tenantinfo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"use strict";
import { stub } from 'sinon';

import expect from 'expect.js';

import {extractTenantBaseUrlOption} from '../src/core/index';

describe("extractTenantBaseUrlOption", () => {

it('should return the configurationBaseUrl', () => {

var url = extractTenantBaseUrlOption({
configurationBaseUrl: 'https://test.com'
}, 'me.auth0.com');

expect(url).to.be('https://test.com')

});

it('should return the assetsUrl', () => {

var url = extractTenantBaseUrlOption({
assetsUrl: 'https://test.com'
}, 'me.auth0.com');

expect(url).to.be('https://test.com')

});

it('should return the cdn url', () => {

var url = extractTenantBaseUrlOption({

}, 'me.auth0.com');

expect(url).to.be('https://cdn.auth0.com/tenants/v1/me.js')

});

it('should return the regionalized cdn url', () => {

var url = extractTenantBaseUrlOption({

}, 'me.eu.auth0.com');

expect(url).to.be('https://cdn.eu.auth0.com/tenants/v1/me.js')

});

it('should return the instance url', () => {

var url = extractTenantBaseUrlOption({

}, 'auth.random.com');

expect(url).to.be('https://auth.random.com/tenants/v1/auth.js')

});

});

0 comments on commit 91f5cc3

Please sign in to comment.