forked from sombochea/verdaccio-ui
committed by
Ayush Sharma
parent
1070e5c3aa
commit
9d7be476ad
21
test/unit/components/store/login.js
Normal file
21
test/unit/components/store/login.js
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user