本文整理匯總了TypeScript中assert.throws函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript throws函數的具體用法?TypeScript throws怎麽用?TypeScript throws使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了throws函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should not accept a selector to an unknown element as input', function() {
assert.throws(function() {
makeDOMDriver('#nonsenseIdToNothing');
}, /Cannot render into unknown element/);
});
示例2: test
test('throws if bad ++opt name', () => {
assert.throws(() => commandParsers.write('++foo=foo'));
});
示例3: it
it('does not load invalid YAML', () => assert.throws(() => load('petstore-invalid.yaml')));
示例4: ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload
export function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload() {
let target = function() { };
assert.throws(() => Reflect.decorate(undefined, target, undefined, undefined), TypeError);
}
示例5: test
test('register command - no handler', function () {
assert.throws(() => CommandsRegistry.registerCommand('foo', null));
});
示例6: it
it("does not infinite loop on incomplete JSX", () => {
throws(() => transform("const x = <", {transforms: ["jsx"]}));
});
示例7: ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload
export function ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload() {
let decorators: (ClassDecorator | MethodDecorator | PropertyDecorator)[] = [];
let target = 1;
let name = "name";
assert.throws(() => Reflect.decorate(decorators, target, name, undefined), TypeError);
}
示例8: it
it('should throw if second argument is not an object', function() {
assert.throws(() => {
(run as any)(() => {}, 'not an object');
}, /Second argument given to Cycle must be an object with driver functions/i);
});
示例9: test
test("try to read lines that don't exist", () => {
assert.equal(vscode.window.activeTextEditor.document.lineCount, 1);
assert.throws(() => TextEditor.readLineAt(1), RangeError);
assert.throws(() => TextEditor.readLineAt(2), RangeError);
});