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/lib/load-script-test.js
Robin Ward 6f25f17360
DEV: Revisit skipped tests (#15769)
* Some are no longer flaky or easily fixed

* Some are out of date or test things we can't do accurately (scroll
  position) and are removed.

* Unwinds some uppy tests and makes sure all promises and runloops are
  resolved.

Everything has been run in legacy/ember cli multiple times to ensure no
obvious suite regressions.
2022-02-02 12:09:03 -05:00

28 lines
894 B
JavaScript

import { cacheBuster } from "discourse/lib/load-script";
import { module, test } from "qunit";
import { PUBLIC_JS_VERSIONS as jsVersions } from "discourse/lib/public-js-versions";
module("Unit | Utility | load-script", function () {
test("works when a value is not present", function (assert) {
assert.strictEqual(
cacheBuster("/javascripts/my-script.js"),
"/javascripts/my-script.js"
);
assert.strictEqual(
cacheBuster("/javascripts/my-project/script.js"),
"/javascripts/my-project/script.js"
);
});
test("generates URLs with version number in the query params", function (assert) {
assert.strictEqual(
cacheBuster("/javascripts/pikaday.js"),
`/javascripts/${jsVersions["pikaday.js"]}`
);
assert.strictEqual(
cacheBuster("/javascripts/ace/ace.js"),
`/javascripts/${jsVersions["ace/ace.js"]}`
);
});
});