peter angular mock

Solutions on MaxInterview for peter angular mock by the best coders in the world

showing results for - "peter angular mock"
Rik
12 Jul 2017
1// Fake todos and response object
2const todos = [
3  'shop groceries',
4  'mow the lawn',
5  'take the cat to the vet'
6];
7const okResponse = new Response(JSON.stringify(todos), {
8  status: 200,
9  statusText: 'OK',
10});
11
12describe('TodoService', () => {
13  it('gets the to-dos', async () => {
14    // Arrange
15    const fetchSpy = jasmine.createSpy('fetch')
16      .and.returnValue(okResponse);
17    const todoService = new TodoService(fetchSpy);
18
19    // Act
20    const actualTodos = await todoService.getTodos();
21
22    // Assert
23    expect(actualTodos).toEqual(todos);
24    expect(fetchSpy).toHaveBeenCalledWith('/todos');
25  });
26});
27