mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
tests: Create base class that ApiUser and ApiGroup inherit from
This commit is contained in:
@@ -15,32 +15,36 @@ i18n.translations = require('../../website/src/libs/i18n.js').translations;
|
|||||||
|
|
||||||
const API_TEST_SERVER_PORT = 3003;
|
const API_TEST_SERVER_PORT = 3003;
|
||||||
|
|
||||||
class ApiUser {
|
class ApiObject {
|
||||||
constructor (options) {
|
constructor (options) {
|
||||||
assign(this, options);
|
assign(this, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
update (options) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
_updateDocument(this._docType, this, options, resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ApiUser extends ApiObject {
|
||||||
|
constructor (options) {
|
||||||
|
super(options);
|
||||||
|
|
||||||
|
this._docType = 'users';
|
||||||
|
|
||||||
this.get = _requestMaker(this, 'get');
|
this.get = _requestMaker(this, 'get');
|
||||||
this.post = _requestMaker(this, 'post');
|
this.post = _requestMaker(this, 'post');
|
||||||
this.put = _requestMaker(this, 'put');
|
this.put = _requestMaker(this, 'put');
|
||||||
this.del = _requestMaker(this, 'del');
|
this.del = _requestMaker(this, 'del');
|
||||||
}
|
}
|
||||||
|
|
||||||
update (options) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
_updateDocument('users', this, options, resolve);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApiGroup {
|
class ApiGroup extends ApiObject {
|
||||||
constructor (options) {
|
constructor (options) {
|
||||||
assign(this, options);
|
super(options);
|
||||||
}
|
|
||||||
|
|
||||||
update (options) {
|
this._docType = 'groups';
|
||||||
return new Promise((resolve) => {
|
|
||||||
_updateDocument('groups', this, options, resolve);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user