gruntjs - Running tests with localStorage -



gruntjs - Running tests with localStorage -

i have followed this tutorial codelab , yeoman. when implemented right using local storage store todolist. have problems setting tests, test if works. i've got far:

'use strict'; describe('controller: mainctrl', function () { // load controller's module beforeeach(module('yeotodoapp'), module('localstoragemodule')); var mainctrl, scope; // initialize controller , mock scope beforeeach(inject(function ($controller, $rootscope, $httpbackend) { scope = $rootscope.$new(); mainctrl = $controller('mainctrl', { $scope: scope }); })); it('should add together items 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 together items list 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); }); });

the error

line 12 col 68 '$httpbackend' defined never used. });

how write unit tests sit down local storage?

your setup right (after removed $httpbackend arguments list)

controller: mainctrl should add together items list remove failed

this error simple test error, means code somewhere doesnt work expected (your sec test fails)

i myself check todos length, , not result of mathematical operation.

i write tests test this:

it('should add together items list remove', function () { scope.todo = 'test 1'; expect(scope.todos.length).tobe(0); scope.addtodo(); expect(scope.todos.length).tobe(1); scope.removetodo(0); expect(scope.todos.length).tobe(0); });

you utilize jasmine test-tool. jasmine logs on errors expectation fails, should

expect '1' '0'

go there!

gruntjs yeoman yeoman-generator-angular

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

html - Submenu setup with jquery and effect 'fold' -

ruby on rails - Devise Logout Error in RoR -