我的MaxNodeOccurs
函数中有以下代码,用于检查参数是否有效,如果不是则抛出异常:
if (!nodeTypeParamIsValid()) {
throw new Error('nodeType should be specified and should not be empty string');
}
function nodeTypeParamIsValid() {
return !(ng.isUndefined(nodeType) || nodeType === null || nodeType === "");
}
现在我正在为此功能编写测试,我想知道我是否应该为nodeType
param undefined
,null
或{{1}编写测试}}?
像这样:
empty string
或者仅仅为it('should throw exception if nodeType is undefined', function () {
expect(MaxNodeOccursService.bind(null, undefined, 0)).toThrow(new Error('nodeType should be specified and should not be empty string'));
});
it('should throw exception if nodeType is null', function () {
expect(MaxNodeOccursService.bind(null, null, 0)).toThrow(new Error('nodeType should be specified and should not be empty string'));
});
it('should throw exception if nodeType is an empty string', function () {
expect(MaxNodeOccursService.bind(null, "", 0)).toThrow(new Error('nodeType should be specified and should not be empty string'));
});
写一个测试说法以确保投掷出来是否足够?