当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.isRejected方法代码示例

本文整理汇总了TypeScript中chai.assert.isRejected方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.isRejected方法的具体用法?TypeScript assert.isRejected怎么用?TypeScript assert.isRejected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chai.assert的用法示例。


在下文中一共展示了assert.isRejected方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

		it("throws correct error when current operating system is not supported", async () => {
			const invalidPlatform = "invalid_platform";
			const testInjector = createTestInjector(invalidPlatform);

			const net = testInjector.resolve<INet>(Net);
			await assert.isRejected(net.waitForPortToListen({ port: 18181, timeout: 50, interval: 1 }), `Unable to check for free ports on ${invalidPlatform}. Supported platforms are: darwin, linux, win32`);
		});
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:7,代码来源:net-service.ts

示例2: it

			it("fails when the templateVersion is invalid", async () => {
				const notSupportedVersionString = "not supported version";
				const testInjector = createTestInjector({ packageJsonContent: { nativescript: { templateVersion: notSupportedVersionString } } });
				const projectTemplatesService = testInjector.resolve<IProjectTemplatesService>("projectTemplatesService");
				const expectedError = format(constants.ProjectTemplateErrors.InvalidTemplateVersionStringFormat, `tns-template-hello-world-ts@${compatibleTemplateVersion}`, notSupportedVersionString);
				await assert.isRejected(projectTemplatesService.prepareTemplate("typescript", "tempFolder"), expectedError);
			});
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:7,代码来源:project-templates-service.ts

示例3: async

			const assertThrows = async (methodName: string): Promise<void> => {
				const instance: any = new InvokeBeforeDecoratorsTest();
				assert.isFalse(instance.isInvokeBeforeMethodCalled);
				const expectedResult = 1;
				await assert.isRejected(instance[methodName](expectedResult), expectedResult);
				assert.isTrue(instance.isInvokeBeforeMethodCalled);
			};
开发者ID:telerik,项目名称:mobile-cli-lib,代码行数:7,代码来源:decorators.ts

示例4: it

				it("should setup manually when cloud extension is installed", async () => {
					mockDoctorService( { canExecuteLocalBuild: false, mockSetupScript: true });
					mockPrompter({ firstCallOptionName: PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME, secondCallOptionName: PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME });
					mockNativeScriptCloudExtensionService({ isInstalled: true });

					await assert.isRejected(platformEnvironmentRequirements.checkEnvironmentRequirements(platform), manuallySetupErrorMessage);
				});
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:7,代码来源:platform-environment-requirements.ts

示例5: it

 it('should throw Error', () => {
     // TODO: create new route with no post route defined
     assert.isRejected(
         Promise.resolve(
             helloRoute.parse({ url: 'spy' }, new MockReq({ method: 'POST' }), null)
         )
     );
 });
开发者ID:fosenutvikling,项目名称:fuhttp-ts,代码行数:8,代码来源:Route.test.ts

示例6: it

			it("validate method throws", async () => {
				let project: Project.IProject = testInjector.resolve("project");
				project.capabilities.canChangeFrameworkVersion = false;
				mobileFwCP = new setVersionFile.MobileFrameworkCommandParameter(testInjector.resolve("cordovaMigrationService"),
					testInjector.resolve("project"), testInjector.resolve("errors"), testInjector.resolve("nativeScriptMigrationService"),
					testInjector.resolve("projectConstants"));
				await assert.isRejected(mobileFwCP.validate("1.0.0"), "You cannot change FrameworkVersion of \'Cordova\' project.");
			});
开发者ID:Icenium,项目名称:icenium-cli,代码行数:8,代码来源:framework-versions.ts

示例7: it

    it("should bubble up that error", async () => {
      const fakeError = new Error(s.random.string());

      sinon.stub(memoryStub, "set").callsFake(() => {
        throw fakeError;
      });

      await assert.isRejected(bucket.get(key, name), fakeError.message);
      memoryStub.set.restore();
    });
开发者ID:taoyuan,项目名称:kvs,代码行数:10,代码来源:load.test.ts

示例8: it

		it("fails with correct error when the destination stream raises error event", async () => {
			const pacoteService = setupTest();

			const pacoteExtractPackagePromise = pacoteService.extractPackage(packageName, destinationDir);
			setImmediate(() => {
				tarExtractDestinationStream.emit("error", new Error(errorMessage));
			});

			await assert.isRejected(pacoteExtractPackagePromise, errorMessage);
		});
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:10,代码来源:pacote-service.ts


注:本文中的chai.assert.isRejected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。