it('should validate the category', () => { return gplay.list({ category: 'wrong', collection: gplay.collection.TOP_FREE }) .then(assert.fail) .catch((e) => assert.equal(e.message, 'Invalid category wrong')); });
it('should validate the age range', () => { return gplay.list({ category: gplay.category.GAME_ACTION, collection: gplay.collection.TOP_FREE, age: 'elderly' }) .then(assert.fail) .catch((e) => assert.equal(e.message, 'Invalid age range elderly')); });
try { generate(30, { number: false, lowercase: false, uppercase: false, special: false }); assert.fail('should have fail'); } catch (e) { expect(e).to.be.instanceOf(BadParameters);
try { await builder.getActiveVersionIds(['app1', 'app2'], 'f8c64e2a-3333-3a09-8f78-39d7adc76ec5', 'westus', 3, 1000) assert.fail() } catch (e) { assert.equal(e.message, 'You do not have access')
sort: 'invalid' }) .then(assert.fail) .catch((e) => assert.equal(e.message, 'Invalid sort invalid')); });
try { await builder.getActiveVersionIds(['app1', 'app2'], 'f8c64e2a-3333-3a09-8f78-39d7adc76ec5', 'westus', 3, 1000) assert.fail() } catch (e) { assert.equal(e.message, 'Rate limit is exceeded')
it('should validate the collection', () => { return gplay.list({ category: gplay.category.GAME_ACTION, collection: 'wrong' }) .then(assert.fail) .catch((e) => assert.equal(e.message, 'Invalid collection wrong')); });
describe('LICENSE', function() { it('should have correct year', function(done) { var licenseFile = fs.readFileSync('LICENSE.md', 'utf8'); var licenseYear = licenseFile.split('\n')[2].split(/[ ,]/)[2]; var thisYear = (new Date()).getFullYear(); if (licenseYear != thisYear) { assert.fail(thisYear, licenseYear, "LICENSE year is not correct") } else { done() } }) });
it("fail", () => { expect(() => { assert.fail(0, 1, "this has failed"); }).to.throw(AssertionError, "this has failed"); });
it("should fail if the package.json file does not exist", async () => { try { await npmPublish(); assert.fail("An error should have been thrown!"); } catch (error) { expect(error).to.be.an.instanceOf(Error); expect(error.message).to.include("Unable to read package.json \nENOENT: no such file or directory"); } files.assert.doesNotExist("home/.npmrc"); files.assert.doesNotExist("workspace/package.json"); npm.assert.didNotRun(); });
it("should fail if the NPM registry URL is invalid", async () => { files.create([ { path: "workspace/package.json", contents: { name: "my-lib", version: "1.2.3" }}, ]); try { await npmPublish({ registry: "example.com" }); assert.fail("An error should have been thrown!"); } catch (error) { expect(error).to.be.an.instanceOf(TypeError); expect(error.message).to.equal("Invalid URL: example.com"); } files.assert.doesNotExist("home/.npmrc"); npm.assert.ran(0); });
it("should error when dequeuing on an empty buffer", function () { var buf = new CircularBuffer(size); try { buf.deq(); } catch (e) { // yay! we caught an error return; } assert.fail("No error after dequeueing empty buffer", "Error after dequeueing empty buffer"); });
it("should error when shifting on an empty buffer", function () { var buf = new CircularBuffer(size); try { buf.shift(); } catch (e) { // yay! we caught an error return; } assert.fail("No error after shifting empty buffer", "Error after shifting empty buffer"); });
it("should fail if the package name is invalid", async () => { files.create([ { path: "workspace/package.json", contents: { name: "\n \t" }}, ]); try { await npmPublish(); assert.fail("An error should have been thrown!"); } catch (error) { expect(error).to.be.an.instanceOf(TypeError); expect(error.message).to.equal("Unable to parse package.json \nInvalid package name"); } files.assert.doesNotExist("home/.npmrc"); npm.assert.didNotRun(); });
it("should fail if the package version is invalid", async () => { files.create([ { path: "workspace/package.json", contents: { name: "my-lib", version: "hello, world" }}, ]); try { await npmPublish(); assert.fail("An error should have been thrown!"); } catch (error) { expect(error).to.be.an.instanceOf(TypeError); expect(error.message).to.equal("Unable to parse package.json \nInvalid Version: hello, world"); } files.assert.doesNotExist("home/.npmrc"); npm.assert.didNotRun(); });