mirror of
https://github.com/SomboChea/ui
synced 2024-11-05 14:14:26 +07:00
9d7be476ad
add new json snapshot serializer
22 lines
542 B
JavaScript
22 lines
542 B
JavaScript
import {API_ERROR} from '../../../../src/lib/constants';
|
|
/**
|
|
* 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
|
|
});
|
|
}
|
|
});
|
|
}
|