1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/webui/components/store/login.js

22 lines
545 B
JavaScript
Raw Normal View History

import {API_ERROR} from '../../../../../src/lib/constants';
2017-12-01 20:04:01 +01:00
/**
* API mock for login endpoint
* @param {object} config configuration of api call
* @returns {promise}
2017-12-01 20:04:01 +01:00
*/
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'
});
2017-12-01 20:04:01 +01:00
} else {
reject({
error: API_ERROR.BAD_USERNAME_PASSWORD
});
2017-12-01 20:04:01 +01:00
}
});
}