mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
9cd3ccb408
* fix: login without reload (#678) (#679) * fix: implements code review suggestions (#914) * refactor: adds scope to the app * refactor: handles null value from localstorage for username * refactor: removes text type from <Input /> * refactor: replaces isNull with isNil * refactor: improves makeLogin method * refactor: adds error from api constant * fix: updates error using API_ERROR constant in tests * refactor: updates regex for moduleMapper in jest config
22 lines
545 B
JavaScript
22 lines
545 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
|
|
});
|
|
}
|
|
});
|
|
}
|