mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Refactored Admin API test agent to use async/await
no issue - Improves readability of what's going on in the code.
This commit is contained in:
parent
6271e2f5f3
commit
29e5d08210
1 changed files with 14 additions and 15 deletions
|
@ -20,13 +20,13 @@ class AdminAPITestAgent extends TestAgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginAs(email, password) {
|
async loginAs(email, password) {
|
||||||
await this.post('/session/')
|
const res = await this.post('/session/')
|
||||||
.body({
|
.body({
|
||||||
grant_type: 'password',
|
grant_type: 'password',
|
||||||
username: email,
|
username: email,
|
||||||
password: password
|
password: password
|
||||||
})
|
});
|
||||||
.then(function then(res) {
|
|
||||||
if (res.statusCode === 302) {
|
if (res.statusCode === 302) {
|
||||||
// This can happen if you already have an instance running e.g. if you've been using Ghost CLI recently
|
// This can happen if you already have an instance running e.g. if you've been using Ghost CLI recently
|
||||||
throw new errors.IncorrectUsageError({
|
throw new errors.IncorrectUsageError({
|
||||||
|
@ -39,7 +39,6 @@ class AdminAPITestAgent extends TestAgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.headers['set-cookie'];
|
return res.headers['set-cookie'];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginAsOwner() {
|
async loginAsOwner() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue