From 2d56663fc4ec26df41ddde77400cbe52a77f6915 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 1 Sep 2020 16:42:22 -0400 Subject: [PATCH] REFACTOR: Remove `_.clone` which is not deep --- .../poll/assets/javascripts/widgets/discourse-poll.js.es6 | 2 +- test/javascripts/acceptance/user-bookmarks-test.js | 5 ++++- test/javascripts/acceptance/user-card-test.js | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 index acff44d2463..68aff3bdd73 100644 --- a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 +++ b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 @@ -211,7 +211,7 @@ createWidget("discourse-poll-standard-results", { const voters = poll.get("voters"); const isPublic = poll.get("public"); - const ordered = _.clone(options).sort((a, b) => { + const ordered = [...options].sort((a, b) => { if (a.votes < b.votes) { return 1; } else if (a.votes === b.votes) { diff --git a/test/javascripts/acceptance/user-bookmarks-test.js b/test/javascripts/acceptance/user-bookmarks-test.js index 51dead8606d..f7a92a8c0a5 100644 --- a/test/javascripts/acceptance/user-bookmarks-test.js +++ b/test/javascripts/acceptance/user-bookmarks-test.js @@ -22,7 +22,10 @@ test("listing user bookmarks", async assert => { }); test("removing a bookmark with a reminder shows a confirmation", async assert => { - let listResponse = _.clone(userFixtures["/u/eviltrout/bookmarks.json"]); + let listResponse = Object.assign( + {}, + userFixtures["/u/eviltrout/bookmarks.json"] + ); listResponse.user_bookmark_list.bookmarks[0].reminder_at = "2028-01-01T08:00"; pretender.get("/u/eviltrout/bookmarks.json", () => [ 200, diff --git a/test/javascripts/acceptance/user-card-test.js b/test/javascripts/acceptance/user-card-test.js index c78f791080b..e17b640543c 100644 --- a/test/javascripts/acceptance/user-card-test.js +++ b/test/javascripts/acceptance/user-card-test.js @@ -12,7 +12,7 @@ acceptance("User Card - Show Local Time", { QUnit.skip("user card local time", async assert => { User.current().changeTimezone("Australia/Brisbane"); - let cardResponse = _.clone(userFixtures["/u/eviltrout/card.json"]); + let cardResponse = Object.assign({}, userFixtures["/u/eviltrout/card.json"]); cardResponse.user.timezone = "Australia/Perth"; pretender.get("/u/eviltrout/card.json", () => [ @@ -39,7 +39,7 @@ QUnit.skip("user card local time", async assert => { "user card contains the user's local time" ); - cardResponse = _.clone(userFixtures["/u/charlie/card.json"]); + cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]); cardResponse.user.timezone = "America/New_York"; pretender.get("/u/charlie/card.json", () => [ @@ -68,7 +68,7 @@ QUnit.test( "user card local time - does not update timezone for another user", async assert => { User.current().changeTimezone("Australia/Brisbane"); - let cardResponse = _.clone(userFixtures["/u/charlie/card.json"]); + let cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]); delete cardResponse.user.timezone; pretender.get("/u/charlie/card.json", () => [