From 4cfc350b09ba6d4d873fea7072ca453efdc0ae43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:13:32 -0300 Subject: [PATCH] DEV: Fix linting issue and failing post test (#29989) --- app/assets/javascripts/discourse/app/models/post.js | 2 +- .../javascripts/discourse/tests/unit/models/post-test.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.js index 69cdd292f9b..d6264dac0ba 100644 --- a/app/assets/javascripts/discourse/app/models/post.js +++ b/app/assets/javascripts/discourse/app/models/post.js @@ -63,7 +63,7 @@ function trackedPostProperty(target, propertyKey, descriptor) { export default class Post extends RestModel { static munge(json) { - json.likeAction = null; + json.likeAction ??= null; if (json.actions_summary) { const lookup = EmberObject.create(); diff --git a/app/assets/javascripts/discourse/tests/unit/models/post-test.js b/app/assets/javascripts/discourse/tests/unit/models/post-test.js index dc30ffca4a8..0a44de6e418 100644 --- a/app/assets/javascripts/discourse/tests/unit/models/post-test.js +++ b/app/assets/javascripts/discourse/tests/unit/models/post-test.js @@ -43,6 +43,12 @@ module("Unit | Model | post", function (hooks) { likeAction: null, // `likeAction` is a tracked property from the model added using `@trackedPostProperty` }); + // asserts that Object.keys(post) does not contain "likeAction" + assert.false( + Object.keys(post).includes("likeAction"), + "Object.keys does not enumerate `likeAction`" + ); + post.updateFromPost( this.store.createRecord("post", { raw: "different raw", @@ -131,6 +137,6 @@ module("Unit | Model | post", function (hooks) { id: 1173, }); - assert.ok(post.likeAction === null, "likeAction was reset to null"); + assert.strictEqual(post.likeAction, null, "likeAction was reset to null"); }); });