mattermost-mobile/test/client/client.test.js
Harrison Healey 543ccb8fe6 Switched client.js to fully use Promises (#23)
* Made sanity tests run without an internet connection

* Removed onRequest parameter from Client methods

* Switched client.js to fully use Promises

* Fix mock response for login

* Fixed test_helper.js to actually use the configured url
2016-10-18 10:46:30 -04:00

42 lines
1.1 KiB
JavaScript

// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import fetchMock from 'fetch_mock';
import TestHelper from 'test_helper.js';
const fakeNotFoundResp = {
status: 404,
body: {
id: 'api.context.404.app_error',
message: 'Sorry, we could not find the page.',
detailed_error: [
"There doesn't appear to be an api call for the url='/api/v3/fake/url/general/ping'.",
'Typo? are you missing a team_id or user_id as part of the url?'
].join(' '),
status_code: 404
}
};
fetchMock.get(/\/ping/, (url) => {
if (url.match(/\/fake\/url/)) {
return fakeNotFoundResp;
}
return {
server_time: `${Date.now()}`,
version: '3.4.0'
};
});
fetchMock.post(/\/log_client/, {
status: 200,
headers: {'Content-Type': 'application/json'},
body: {status: 'OK'}
});
describe('Client', () => {
it('doFetch', async () => {
const client = TestHelper.createClient();
return client.doFetch(`${client.getGeneralRoute()}/ping`, {});
});
});