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
Juan Picado @jotadeveloper 49c6191bb5
refactor: relocate unit test
no logic change, just path updates
2018-06-23 20:57:12 +02:00

25 lines
590 B
JavaScript

/**
* API mock for login endpoint
* @param {object} config configuration of api call
* @returns {promise}
*/
export default function(config) {
return new Promise(function(resolve, reject) {
const body = JSON.parse(config.body);
if (body.username === 'sam' && body.password === '1234') {
return new Promise(function(resolve) {
resolve({
json: function() {
return {
username: 'sam',
token: 'TEST_TOKEN'
}
}
});
});
} else {
throw Error('Unauthorized');
}
});
}