UNPKG

@zendesk/zcli-core

Version:

ZCLI core libraries and services

29 lines (28 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const test_1 = require("@oclif/test"); const authUtils_1 = require("./authUtils"); describe('authUtils', () => { describe('parseSubdomain', () => { test_1.test .it('should extract the subdomain from a url', async () => { (0, test_1.expect)((0, authUtils_1.parseSubdomain)('https://Test1.zeNDEsk.com/')).to.equal('test1'); (0, test_1.expect)((0, authUtils_1.parseSubdomain)(' hTTp://tEst2.zendesk.com/ ')).to.equal('test2'); (0, test_1.expect)((0, authUtils_1.parseSubdomain)('test3.zendesk.com ')).to.equal('test3'); (0, test_1.expect)((0, authUtils_1.parseSubdomain)('test4')).to.equal('test4'); }); }); describe('getAccount', () => { test_1.test.it('should get the account from subdomain and eventually domain', () => { (0, test_1.expect)((0, authUtils_1.getAccount)('test')).to.equal('test'); (0, test_1.expect)((0, authUtils_1.getAccount)('test', 'example.com')).to.equal('test.example.com'); }); }); describe('getProfileFromAccount', () => { test_1.test.it('should get the profile from account', () => { (0, test_1.expect)((0, authUtils_1.getProfileFromAccount)('test')).to.deep.equal({ subdomain: 'test' }); (0, test_1.expect)((0, authUtils_1.getProfileFromAccount)('test.example.com')).to.deep.equal({ subdomain: 'test', domain: 'example.com' }); (0, test_1.expect)((0, authUtils_1.getProfileFromAccount)('test.subdomain.example.com')).to.deep.equal({ subdomain: 'test', domain: 'subdomain.example.com' }); }); }); });