I have a method in a service that removes items older than 60 days from a list.
self.removerAntigas = function () {
var dataCorte = new Date();
var dataAux = dataCorte.getDate();
dataCorte.setDate(dataAux - 60);
itens.forEach(function (item) {
if (item.data <= dataCorte) {
itens.splice (itens.indexOf(item),1);
}
});
};
I also have the method that gets all the items in this list:
self.obterTodos = function (){
return itens;
}
And the add method:
self.adicionar = function () {
var item = {
data: new Date(),
latitude: 0,
longitude: 0,
conectado: true,
sincronizado: false
};
itens.push(item);
};
How can I write a test using Jasmine, letting me know if I have removed the correct items from this list?