Testing Angular services
Let's first create a Todo.ts model class that represents the Todo item. The following code snippet shows the content of the Todo class:
export class Todo { 
    title: string; 
    completed: boolean;
    constructor(title: string) { 
        this.title = title; 
        this.completed = false; 
    } 
    set isCompleted(value: boolean) { 
        this.completed = value; 
    } 
} Next, create a service todo.service.ts that constructs the list of Todo items in the constructor. The complete code of todo.service.ts is as shown:
import { Todo } from './todo' 
export class TodoService { 
    todos: Array<Todo> 
    constructor() { 
        this.todos = [new Todo('First item'), 
        new Todo('Second item'), 
        new Todo('Third item')]; 
    } 
    getPending() { 
        return this.todos.filter((todo: Todo) => todo.completed === 
        false); 
    } 
    getCompleted() { 
        return this.todos.filter((todo: Todo) => todo.completed === 
   ...