From 51452f3947401e8573c48c1e5d1e7615bab2435d Mon Sep 17 00:00:00 2001 From: Noah Johnson Date: Tue, 1 Oct 2019 09:38:34 -0500 Subject: [PATCH] feat(constructor and base url): Adds a flag to the constructor that allows for use of custom domains re #6 --- test/tw.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/tw.js b/test/tw.js index 9740a37..c2145d9 100644 --- a/test/tw.js +++ b/test/tw.js @@ -63,6 +63,14 @@ describe('#teamwork', function () { delete process.env.TW_API }) + it('throws an error when an invalid custom domain is passed', function () { + expect(() => tw(api, 'mycompany.com', true)).to.throw(Error, 'custom domains must be fully qualified and include protocol without a trailing slash') + }) + + it('throws an error when a custom domain with no protocol', function () { + expect(() => tw(api, 'tw.mycompany.com', true)).to.throw(Error, 'custom domains must be fully qualified and include protocol without a trailing slash') + }) + // Success // it('returns the default teamwork class', function () { @@ -79,6 +87,11 @@ describe('#teamwork', function () { delete process.env.TW_SUB }) + it('returns the default teamwork class when a custom domain is used', function () { + const instance = tw(api, 'https://projects.mydomain.net', true) + expect(instance).to.be.an.instanceof(teamwork) + }) + it('returns correct Class instance when called', function () { const instance = tw(api, domain)