私はCodelab と yeoman のこのチュートリアルに従いました。正しく実装すると、ローカル ストレージを使用して TodoList を保存できます。これが機能するかどうかをテストするために、テストのセットアップに問題があります。これは私がこれまでに持っているものです:
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('yeoTodoApp'), module('LocalStorageModule'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope, $httpBackend) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('should add items to the list', function () {
var beforeLength = scope.todos.length;
scope.todo = 'Test 1';
scope.addTodo();
var afterLength = scope.todos.length;
expect(afterLength-beforeLength).toBe(1);
});
it('should add items to the list then remove', function () {
var beforeLength = scope.todos.length;
scope.todo = 'Test 1';
scope.addTodo();
scope.removeTodo(0);
var afterLength = scope.todos.length;
expect(afterLength-beforeLength).toBe(0);
});
});
私が得るエラーは
line 12 col 68 '$httpBackend' が定義されていますが、使用されていません。});
ローカル ストレージを配置するための単体テストをどのように作成すればよいですか?