本文整理汇总了TypeScript中test/helper.assert.throws方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.throws方法的具体用法?TypeScript assert.throws怎么用?TypeScript assert.throws使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test/helper.assert
的用法示例。
在下文中一共展示了assert.throws方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('throws meaningful error messages', function() {
assert.throws(function callWithABadTagNameArgument() {
var badTagName = 42;
domElement = createDOMElement(badTagName);
},
'createDOMElement expects the first argument, tagName, to be a DOM element'
);
assert.throws(function callWithABadStyleArgument() {
var badStyle = 42;
domElement = createDOMElement('thing', badStyle);
},
'createDOMElement expects the second argument, style, to be a hash'
);
assert.throws(function callWithABadAttributesArgument() {
var goodStyle = {};
var badAttributes = 42;
domElement = createDOMElement('thing', goodStyle, badAttributes);
},
'createDOMElement expects the third argument, attributes, to be a hash'
);
});
示例2: it
it('validates input', function() {
var domElement = createDOMElement('div');
var style = { color: 'red' };
assert.throws(function() {
toggleStyle(42);
},
'toggleStyle expects the first argument to be a DOM element'
);
assert.throws(function() {
toggleStyle(domElement, 42);
},
'toggleStyle expects the second argument, style, to be a hash'
);
assert.throws(function() {
toggleStyle(domElement, style, 42);
},
'toggleStyle expects the third argument, onEventName, to be a string'
);
assert.throws(function() {
toggleStyle(domElement, style, 'mouseenter', 42);
},
'toggleStyle expects the third argument, offEventName, to be a string'
);
});
示例3: it
it('validates input', function() {
assert.throws(function() {
addHoverEffect(42);
},
'addHoverEffect expects the first argument to be a DOM element'
);
assert.throws(function() {
addHoverEffect(domElement, 42);
},
'addHoverEffect expects the second argument, style, to be a hash'
);
});
示例4: it
it('throws meaningful errors', function() {
assert.throws(function runWithoutTheFirstArgument() {
DateFormatting.format();
},
'DateFormatting.format: the first argument is required and has to be a JS Date instance'
);
assert.throws(function runWithoutTheSecondArgument() {
DateFormatting.format(date);
},
'DateFormatting.format: the second argument is required and has to be a string representing the date format mask to represent date as'
);
});
示例5: it
it('validates input', function() {
assert.throws(function() {
makeRemovable(42);
},
'makeRemovable: the first argument is required to be a DOM element'
);
assert.throws(function() {
makeRemovable(domElement);
},
'makeRemovable: the second argument is required to be a function to call back on remove'
);
});
示例6: it
it('throws meaningful error messages', function() {
assert.throws(function() {
addStyle(42);
},
'addStyle expects the first argument to be a DOM element'
);
assert.throws(function() {
addStyle(createDOMElement('div'), 42);
},
'addStyle expects the second argument to be a hash'
);
});
示例7: it
it('validates input', function() {
assert.throws(function() {
var getValue = getFieldValueCollector([field1, field2, {}]);
getValue();
},
'Every field is expected to have an internalName'
);
assert.throws(function() {
var getValue = getFieldValueCollector([field1, field2, { internalName: 'yes' }]);
getValue();
},
'Every field is expected to have a getValue method'
);
});
示例8: it
it('validates input', function() {
assert.throws(function() {
new CompletionLabel(); // eslint-disable-line no-new
},
'CompletionLabel expects the completionTime argument to be a Date object'
);
});
示例9: it
it('validates input', function() {
assert.throws(function callingWithNonPlainObject() {
Activity.createWithData(42);
},
'Activity.createWithData expects the argument to be a plain JS object'
);
});
示例10: it
it('requires the label text to be a string', function() {
assert.throws(function callingWithInvalidTextLabel() {
new TodoItem(id, 42); // eslint-disable-line no-new
},
'TodoItem constructor expects the first argument, label text, to be a string'
);
});