You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
The earlier commit, d3ce0cb82f, has most of the juicy details on this. In addition to d3ce's changes, we also:
* Use `TestClient` in many integration tests due to subtle behaviour changes in imports when switching to ES6. Namely the behaviour where setting the request function is less reliable in the way we did it, but `TestClient` is very reliable.
* We now use the Olm loader more often to avoid having to maintain so much duplicate code. This makes the imports slightly easier to read.
25 lines
767 B
JavaScript
25 lines
767 B
JavaScript
import {TestClient} from '../TestClient';
|
|
|
|
describe('Login request', function() {
|
|
let client;
|
|
|
|
beforeEach(function() {
|
|
client = new TestClient();
|
|
});
|
|
|
|
afterEach(function() {
|
|
client.stop();
|
|
});
|
|
|
|
it('should store "access_token" and "user_id" if in response', async function() {
|
|
const response = { user_id: 1, access_token: Date.now().toString(16) };
|
|
|
|
client.httpBackend.when('POST', '/login').respond(200, response);
|
|
client.httpBackend.flush('/login', 1, 100);
|
|
await client.client.login('m.login.any', { user: 'test', password: '12312za' });
|
|
|
|
expect(client.client.getAccessToken()).toBe(response.access_token);
|
|
expect(client.client.getUserId()).toBe(response.user_id);
|
|
});
|
|
});
|