0
範圍變量我試圖建立噶單元測試,並在我的測試我想設置一個範圍變量,這樣我可以運行測試。我收到錯誤無法設置未定義的屬性'expandedSeries'。AngularJS設置噶測試
以下是我的代碼。我究竟做錯了什麼?
describe('FormController', function() {
beforeEach(module('userFormApp'));
var $controller;
var $rootScope;
beforeEach(inject(function (_$controller_, _$rootScope_) {
$controller = _$controller_;
$rootScope = _$rootScope_;
}));
describe('$scope.getImageSrc', function() {
var $scope, controller;
beforeEach(function() {
$scope = $rootScope.$new();
controller = $controller('FormController', { $scope: $scope});
});
$scope.expandedSeries = 1;
it('sets variables ', function() {
expect($scope).toBeDefined();
expect($scope.expandedSeries).toBeDefined();
expect($scope.expandedSeries).toEqual(1);
});
});