Created
July 2, 2017 19:08
-
-
Save stevermeister/e4efc989b3198d9db52bf097100d3786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should get one user', inject([XHRBackend, UserService], (mockBackend: MockBackend, service: UserService) => { | |
| mockBackend.connections.subscribe((connection: MockConnection) => { | |
| mockUser = { | |
| name: 'John', | |
| age: 21 | |
| }; | |
| const responseOptions = new ResponseOptions({ body: JSON.stringify(mockUser) }); | |
| connection.mockRespond(new Response(responseOptions)); | |
| expect(connection.request.url).toBe('/users/1'); | |
| }) | |
| service.getOne(1).subscribe((user) => { | |
| expect(user).toEqual(mockUser); | |
| }); | |
| })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment