在 Jasmine 测试中每个“它”有多个匹配器是否正确,否则它们会相互干扰?
我想将这些测试合并为一个:
var mapper = ......... ;
it('should be reviewed if not admin and language not set', inject(function() {
scope.globals.isAdmin = false;
scope.globals.language = '';
mapper.updatedOn.setYear(2013);
expect(scope.isReviewed(mapper)).toBe(true);
}));
it('should disregard mapper date if not admin and language not set', inject(function() {
scope.globals.isAdmin = false;
scope.globals.language = '';
mapper.updatedOn.setYear(2015);
expect(scope.isReviewed(mapper)).toBe(true);
}));
it('should be reviewed if admin and mapper is older', inject(function() {
scope.globals.isAdmin = true;
scope.globals.language = '';
mapper.updatedOn.setYear(2013);
expect(scope.isReviewed(mapper)).toBe(true);
}));
it('should be not reviewed if admin and mapper is newer', inject(function() {
scope.globals.isAdmin = true;
scope.globals.language = '';
mapper.updatedOn.setYear(2015);
expect(scope.isReviewed(mapper)).toBe(false);
}));
it('should be reviewed if not admin, language is set and mapper is older', inject(function() {
scope.globals.isAdmin = false;
scope.globals.language = 'de';
mapper.updatedOn.setYear(2013);
expect(scope.isReviewed(mapper)).toBe(true);
}));
it('should be not reviewed if not admin, language is set and mapper is newer', inject(function() {
scope.globals.isAdmin = false;
scope.globals.language = 'de';
mapper.updatedOn.setYear(2015);
expect(scope.isReviewed(mapper)).toBe(false);
}));
这可能/合理吗?