Code coverage report for js/services/todoStorage.js

Statements: 80% (4 / 5)      Branches: 100% (2 / 2)      Functions: 66.67% (2 / 3)      Lines: 80% (4 / 5)      Ignored: none     

All files » js/services/ » todoStorage.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22          2       2   2   6                
/*global angular */
 
/**
 * Services that persists and retrieves TODOs from localStorage
 */
angular.module('todomvc')
	.factory('todoStorage', function () {
		'use strict';
 
		var STORAGE_ID = 'todos-angularjs';
 
		return {
			get: function () {
				return JSON.parse(localStorage.getItem(STORAGE_ID) || '[]');
			},
 
			put: function (todos) {
				localStorage.setItem(STORAGE_ID, JSON.stringify(todos));
			}
		};
	});