import { HostExtractor } from './HostExtractor'; import { expect } from 'chai'; import { Mock, IMock, It, Times } from 'typemoq'; describe('Host extractor', () => { let $location: IMock; beforeEach(() => { $location = Mock.ofType(); }); function hostFor(hostString: string) { $location.setup(x => x.host()).returns(() => hostString); return new HostExtractor($location.object); } it('should extract the host', () => { const host = hostFor('https://switch.ovoenergy.com'); expect(host.isAgentMode).to.be.false; expect(host.mode).to.equal('Switch'); expect(host.retailer).to.equal('OVO'); }); it('should extract the host for csa mode', () => { const host = hostFor('https://switch-csa-uat.ovoenergy.com'); expect(host.isAgentMode).to.be.true; expect(host.mode).to.equal('Switch'); expect(host.retailer).to.equal('OVO'); }); it('should extract the host for move in', () => { const host = hostFor('https://movein.ovoenergy.com'); expect(host.isAgentMode).to.be.false; expect(host.mode).to.equal('MoveIn'); expect(host.retailer).to.equal('OVO'); }); it('should extract the host for a community', () => { const host = hostFor('https://switch.fairerpower.co.uk'); expect(host.isAgentMode).to.be.false; expect(host.mode).to.equal('Switch'); expect(host.retailer).to.equal('Fairerpower'); }); });