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
Robin Ward 3b81c2d470 FIX: Normalize links by converting them to lower case
The server side does this so the same link on the client side with any
upper case letters does not warn as a duplicate.
2020-12-11 11:16:51 -05:00

49 lines
1.2 KiB
JavaScript

import LinkLookup, { reset } from "discourse/lib/link-lookup";
import { module, test } from "qunit";
import Post from "discourse/models/post";
module("Unit | Utility | link-lookup", function (hooks) {
hooks.afterEach(() => reset());
hooks.beforeEach(function () {
this.post = Post.create();
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]
);
});
});