我创建了一个装饰,它包含一个规则,当它使用的不是同一个班一次扔,它的一个非常基本的版本将是类似以下内容:断言装饰抛出
function someDecorator(target: any) {
var msg = "Decorator can only be applyed once";
if(target.annotated != undefined) throw new Error(msg);
target.annotated = true;
}
所以如果开发者尝试使用开发者超过一次它会抛出:
@someDecorator
@someDecorator // throws
class Test {
}
一切按预期工作由我想写一个单元测试来验证此功能。我正在使用摩卡,柴和sinon。
我怎么能断言someDecorator抛出?