UNPKG

packagecloud

Version:
27 lines (22 loc) 1.03 kB
import PackageCloud from '../packagecloud'; describe("Initialization Actions", () => { it('should throw an error when initializing with no options', function() { expect(function() { new PackageCloud(); }).toThrowError("packagecloud API token is required: {token: packagecloud_api_token}"); }); it('should throw an error when initializing with no API token', function() { expect(function() { new PackageCloud({token: null}); }).toThrowError("token cannot be null or undefined"); }); it('should throw an error when initializing with incorrect param type', function() { expect(function() { new PackageCloud('token'); }).toThrowError("The packagecloud client expects an object with a token field: {token: api_token}"); }); it('should generate the correct base url', function() { var new_pc = new PackageCloud({token: 'test_token2', baseUrl: 'https://packagecloud.io/'}); expect(new_pc.requestOptions.baseUrl).toBe("https://packagecloud.io/api/v1/"); }); });