moduleFor("controller:history"); QUnit.test("displayEdit", function(assert) { const HistoryController = this.subject(); HistoryController.setProperties({ model: { last_revision: 3, current_revision: 3, can_edit: false }, topicController: {} }); assert.equal( HistoryController.get("displayEdit"), false, "it should not display edit button when user cannot edit the post" ); HistoryController.set("model.can_edit", true); assert.equal( HistoryController.get("displayEdit"), true, "it should display edit button when user can edit the post" ); HistoryController.set("topicController", null); assert.equal( HistoryController.get("displayEdit"), false, "it should not display edit button when there is not topic controller" ); HistoryController.set("topicController", {}); HistoryController.set("model.current_revision", 2); assert.equal( HistoryController.get("displayEdit"), false, "it should only display the edit button on the latest revision" ); const html = `

" width="276" height="183">

Column Test
Osama Testing
`; const expectedOutput = `

" width="276" height="183">

Column Test
Osama Testing
`; HistoryController.setProperties({ viewMode: "side_by_side", model: { body_changes: { side_by_side: html } } }); HistoryController.bodyDiffChanged().then(() => { const output = HistoryController.get("bodyDiff"); assert.equal(output, expectedOutput, "it keeps safe HTML"); }); });