* The `javascript:update` rake task failed because recent versions of chart.js use a lowercase filename (`chart.min.js` instead of `Chart.min.js`) * Changed `loadScript()` to use lowercase keys to lookup scripts * `svg-arrow.css` seems to have changed slightly (linebreak at the end of file)
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
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"]}`
|
|
);
|
|
});
|
|
|
|
test("lookups are case-insensitive", (assert) => {
|
|
assert.strictEqual(
|
|
cacheBuster("/javascripts/Chart.min.js"),
|
|
`/javascripts/${jsVersions["chart.min.js"]}`
|
|
);
|
|
assert.strictEqual(
|
|
cacheBuster("/javascripts/chart.min.js"),
|
|
`/javascripts/${jsVersions["chart.min.js"]}`
|
|
);
|
|
});
|
|
});
|