本文整理汇总了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`);
});
示例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);
});
示例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);
};
示例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);
});
示例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)
)
);
});
示例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.");
});
示例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();
});
示例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);
});