我有一个范围变量
$scope.FacilityLocations = [
{ Id: 1, Name: 'All', value: 'all', Selected: true },
{ Id: 2, Name: 'Facility Location 1', value: 'facilityLoc_1', Selected: true },
{ Id: 3, Name: 'Facility Location 2', value: 'facilityLoc_2', Selected: false },
{ Id: 4, Name: 'Facility Location 3', value: 'facilityLoc_3', Selected: false }];
我的测试代码是......
it('Checking array of objects:',function() {
expect($scope.FacilityLocations).toEqual([{ Id: 1, Name: 'All', value: 'all', Selected: true }, { Id: 2, Name: 'Facility Location 1', value: 'facilityLoc_1', Selected: true }, { Id: 3, Name: 'Facility Location 2', value: 'facilityLoc_2', Selected: false }, { Id: 4, Name: 'Facility Location 3', value: 'facilityLoc_3', Selected: false }]);
});
请建议我解决这个问题,我在这里错过了什么。
提前致谢。
的副本答案 0 :(得分:0)
//你必须注入控制器并定义范围
beforeEach(inject(function($controller,$rootScope,_$httpBackend_,_$http_){
controller = $controller('Ctrl', {
$scope: scope
});
}));
//在"中使用范围代替$ scope;"功能