2019-05-02 02:02:46 +07:00
|
|
|
import {API_ERROR} from '../../../../src/lib/constants';
|
2019-04-05 02:23:40 +07:00
|
|
|
/**
|
|
|
|
* API mock for login endpoint
|
|
|
|
* @param {object} config configuration of api call
|
|
|
|
* @returns {promise}
|
|
|
|
*/
|
|
|
|
export default function(config) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const body = JSON.parse(config.body);
|
|
|
|
if (body.username === 'sam' && body.password === '1234') {
|
|
|
|
resolve({
|
|
|
|
username: 'sam',
|
|
|
|
token: 'TEST_TOKEN'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
reject({
|
|
|
|
error: API_ERROR.BAD_USERNAME_PASSWORD
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|