2018-09-26 19:35:49 +02:00
|
|
|
var expect = require('chai').expect;
|
2018-09-26 19:40:49 +02:00
|
|
|
var assert = require('chai').assert;
|
2018-09-26 19:35:49 +02:00
|
|
|
require('dom-test');
|
|
|
|
|
2018-09-27 12:59:21 +02:00
|
|
|
var LocalStorage = require('node-localstorage').LocalStorage;
|
2018-09-27 15:38:56 +02:00
|
|
|
localStorage = new LocalStorage('../scratch');
|
2018-09-27 12:59:21 +02:00
|
|
|
|
2018-09-26 22:07:30 +02:00
|
|
|
var todoApp = "../todoApp.js";
|
|
|
|
|
|
|
|
var addTodoToList = require(todoApp).addTodoToList;
|
|
|
|
var getTodoList = require(todoApp).getTodoList;
|
|
|
|
var foo = require(todoApp).foo;
|
2018-09-27 12:59:21 +02:00
|
|
|
var setLocalStorage = require('../todoApp.js').setLocalStorage;
|
|
|
|
var getLocalStorage = require('../todoApp.js').getLocalStorage;
|
2018-09-28 21:11:33 +02:00
|
|
|
var createTodoEntry = require('../todoApp.js').createTodoEntry;
|
2018-09-26 19:35:49 +02:00
|
|
|
|
2018-09-27 15:38:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-26 22:07:30 +02:00
|
|
|
describe('todoList', function() {
|
2018-09-26 19:35:49 +02:00
|
|
|
it('should return a arry', function() {
|
|
|
|
expect(getTodoList().length).to.equal(0);
|
|
|
|
addTodoToList("foo");
|
|
|
|
expect(getTodoList().length).to.equal(1);
|
2018-09-26 22:07:30 +02:00
|
|
|
expect(getTodoList()).to.deep.equal([{completed: false, todoText: "foo"}])
|
2018-09-26 19:35:49 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-09-27 15:38:56 +02:00
|
|
|
|
|
|
|
|
2018-09-26 19:35:49 +02:00
|
|
|
describe('foo', function() {
|
|
|
|
it('return foo', function() {
|
|
|
|
expect(foo("foo")).to.equal("foo");
|
|
|
|
});
|
|
|
|
});
|
2018-09-27 12:59:21 +02:00
|
|
|
|
2018-09-27 15:38:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe('setLocalStorage and getLocalStorage', () =>{
|
|
|
|
it('set localStorage as string', () =>{
|
2018-09-27 12:59:21 +02:00
|
|
|
setLocalStorage(["foo", 12, "foo bar"]);
|
2018-09-27 15:38:56 +02:00
|
|
|
expect(localStorage.getItem("savedTodoList")).to.equal('["foo",12,"foo bar"]');
|
|
|
|
})
|
|
|
|
it('get localStorage as array', () => {
|
2018-09-27 12:59:21 +02:00
|
|
|
expect(getLocalStorage()).to.deep.equal(["foo", 12, "foo bar"])
|
|
|
|
})
|
|
|
|
})
|