Fixed toJSON method of Tier

This was returning an ObjectID object which is not a JSON primitive
This commit is contained in:
Fabien "egg" O'Carroll 2022-10-24 11:49:24 +07:00
parent 6e862b42e7
commit df145797b3
2 changed files with 2 additions and 2 deletions

View File

@ -186,7 +186,7 @@ module.exports = class Tier {
toJSON() {
return {
id: this.#id,
id: this.#id.toHexString(),
slug: this.#slug,
name: this.#name,
description: this.#description,

View File

@ -99,7 +99,6 @@ describe('Tier', function () {
const tier = await Tier.create(validInput);
const expectedProps = [
'id',
'slug',
'name',
'description',
@ -119,6 +118,7 @@ describe('Tier', function () {
for (const prop of expectedProps) {
assert(tier[prop] === tier.toJSON()[prop]);
}
assert(tier.id.toHexString() === tier.toJSON().id);
});
it('Errors when attempting to set invalid properties', async function () {