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/link-lookup-test.js

52 lines
1.3 KiB
JavaScript

import LinkLookup from "discourse/lib/link-lookup";
import { module, test } from "qunit";
import { getOwner } from "discourse-common/lib/get-owner";
module("Unit | Utility | link-lookup", function (hooks) {
hooks.beforeEach(function () {
const store = getOwner(this).lookup("service:store");
this.post = store.createRecord("post");
this.linkLookup = new LinkLookup({
"en.wikipedia.org/wiki/handheld_game_console": {
post_number: 1,
},
});
});
test("works with https", function (assert) {
assert.ok(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console"
)[0]
);
});
test("works with http", function (assert) {
assert.ok(
this.linkLookup.check(
this.post,
"http://en.wikipedia.org/wiki/handheld_game_console"
)[0]
);
});
test("works with trailing slash", function (assert) {
assert.ok(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console/"
)[0]
);
});
test("works with uppercase characters", function (assert) {
assert.ok(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/Handheld_game_console"
)[0]
);
});
});