This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/services/screen-track-test.js
2021-11-17 20:56:06 +01:00

22 lines
738 B
JavaScript

import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
discourseModule("Unit | Service | screen-track", function () {
test("consolidateTimings", function (assert) {
const tracker = this.container.lookup("service:screen-track");
tracker.consolidateTimings({ 1: 10, 2: 5 }, 10, 1);
tracker.consolidateTimings({ 1: 5, 3: 1 }, 3, 1);
const consolidated = tracker.consolidateTimings({ 1: 5, 3: 1 }, 3, 2);
assert.deepEqual(
consolidated,
[
{ timings: { 1: 15, 2: 5, 3: 1 }, topicTime: 13, topicId: 1 },
{ timings: { 1: 5, 3: 1 }, topicTime: 3, topicId: 2 },
],
"expecting consolidated timings to match correctly"
);
});
});