it('should save/exec named sync', function () { var name = 'sync-op', result = perfy.exec(name, function () { var i = 0; while (i < 10000) { i += 1; } }); expect(result).toBeDefined(); expect(result.time).toEqual(jasmine.any(Number)); expect(perfy.result(name)).toBeDefined(); expect(perfy.exists(name)).toEqual(true); });
it('Test 014 : should generate config munges for queued plugins', function () { fs.copySync(android_two_project, temp); const platformJson = PlatformJson.load(plugins_dir, 'android'); platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }]; const munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider); const spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({}); munger.process(plugins_dir); expect(spy).toHaveBeenCalledWith(jasmine.any(PluginInfo), {}); });
it('Test 002 : should return new instance for every PluginManager.get call', function () { expect(PluginManager.get(FAKE_PLATFORM, FAKE_LOCATIONS)).toEqual(jasmine.any(PluginManager)); expect(PluginManager.get(FAKE_PLATFORM, FAKE_LOCATIONS)) .not.toBe(PluginManager.get(FAKE_PLATFORM, FAKE_LOCATIONS)); });
describe("UUID utility", () => { it("uuid() should generate random UUIDs", () => { const uuid1 = uuid(); const uuid2 = uuid(); expect(uuid1).toEqual(jasmine.any(String)); expect(uuid1.length).toEqual(32); expect(uuid1).not.toEqual(uuid2); }); });
it('should get result', function () { var result = perfy.result('m2'); expect(Boolean(result)).toEqual(true); expect(result.time).toEqual(jasmine.any(Number)); });
it('should be an unprocessable error with custom message and causes', function () { var e = new NspError(NspError.codes.UNPROCESSABLE, 'message', [ 'cause1', 'cause2' ]); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('NspError'); expect(e.code).toBe('UNPROCESSABLE'); expect(e.message).toBe('message'); expect(e.stack).toBeString(); expect(e.toString()).toBe('NspError: message'); expect(e.causes).toEqual([ 'cause1', 'cause2' ]); });
it('Test 003 : should return the same instance via "get" method', function () { expect(CordovaLogger.get()).toBeDefined(); expect(CordovaLogger.get()).toBe(CordovaLogger.get()); expect(CordovaLogger.get()).toEqual(jasmine.any(CordovaLogger)); });
it('should be an internal server error', function () { var e = new NspError(); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('NspError'); expect(e.code).toBe('INTERNAL_SERVER_ERROR'); expect(e.message).toBe('Generic error'); expect(e.causes).toBeEmptyArray(); expect(e.stack).toBeString(); });
it('Test 004 : should have defaults levels', function () { DEFAULT_LEVELS.forEach(function (level) { expect(logger.levels[level]).toBeDefined(); expect(logger.levels[level]).toEqual(jasmine.any(Number)); expect(logger[level]).toBeDefined(); expect(logger[level]).toEqual(jasmine.any(Function)); expect(logger[level].length).toBe(1); }); });
it('should be a 405 error', function () { var e = new HttpError(HttpError.statusCodes.METHOD_NOT_ALLOWED, 'Can\'t delete a Card'); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('HttpError'); expect(e.statusCode).toBe(405); expect(e.statusReason).toBe('Method not allowed'); expect(e.message).toBe('Can\'t delete a Card'); expect(e.causes).toBeEmptyArray(); expect(e.toString()).toBe('HttpError: Can\'t delete a Card'); });
it('should be a forbidden error', function () { var e = new NspError(NspError.codes.FORBIDDEN); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('NspError'); expect(e.code).toBe('FORBIDDEN'); expect(e.message).toBe('The principal is not authorized to execute this task'); expect(e.causes).toBeEmptyArray(); expect(e.stack).toBeString(); expect(e.toString()).toBe('NspError: The principal is not authorized to execute this task'); });
it('should be an invalid error', function () { var e = new NspError(NspError.codes.INVALID); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('NspError'); expect(e.code).toBe('INVALID'); expect(e.message).toBe('Invalid request'); expect(e.stack).toBeString(); expect(e.toString()).toBe('NspError: Invalid request'); });
it('should be a 404 error', function () { var e = new HttpError(HttpError.statusCodes.NOT_FOUND, 'Card not found'); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('HttpError'); expect(e.statusCode).toBe(404); expect(e.statusReason).toBe('Not found'); expect(e.message).toBe('Card not found'); expect(e.causes).toBeEmptyArray(); expect(e.toString()).toBe('HttpError: Card not found'); });
it('should be a not found error', function () { var e = new NspError(NspError.codes.NOT_FOUND); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('NspError'); expect(e.code).toBe('NOT_FOUND'); expect(e.message).toBe('Not found'); expect(e.causes).toBeEmptyArray(); expect(e.stack).toBeString(); expect(e.toString()).toBe('NspError: Not found'); });
it('should be a 409 error', function () { var e = new HttpError(HttpError.statusCodes.CONFLICT, 'Duplicated UUID'); expect(e).toEqual(jasmine.any(Error)); expect(e.name).toBe('HttpError'); expect(e.statusCode).toBe(409); expect(e.statusReason).toBe('Conflict'); expect(e.message).toBe('Duplicated UUID'); expect(e.causes).toBeEmptyArray(); expect(e.toString()).toBe('HttpError: Duplicated UUID'); });