UNPKG

794 BJavaScriptView Raw
1import expect from 'expect';
2import TestClient from '../TestClient';
3
4describe('Login request', function() {
5 let client;
6
7 beforeEach(function() {
8 client = new TestClient();
9 });
10
11 afterEach(function() {
12 client.stop();
13 });
14
15 it('should store "access_token" and "user_id" if in response', async function() {
16 const response = { user_id: 1, access_token: Date.now().toString(16) };
17
18 client.httpBackend.when('POST', '/login').respond(200, response);
19 client.httpBackend.flush('/login', 1, 100);
20 await client.client.login('m.login.any', { user: 'test', password: '12312za' });
21
22 expect(client.client.getAccessToken()).toBe(response.access_token);
23 expect(client.client.getUserId()).toBe(response.user_id);
24 });
25});