summaryrefslogtreecommitdiff
path: root/js_tests/admin/URLify.test.js
blob: 36afd676c9d0881825c0b8ec852c96dd1fa4cf43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* global QUnit, URLify */
"use strict";

QUnit.module("admin.URLify");

QUnit.test("empty string", function (assert) {
    assert.strictEqual(URLify("", 8, true), "");
});

QUnit.test("preserve nonessential words", function (assert) {
    assert.strictEqual(URLify("the D is silent", 15, true), "the-d-is-silent");
});

QUnit.test("strip non-URL characters", function (assert) {
    assert.strictEqual(URLify("D#silent@", 7, true), "dsilent");
});

QUnit.test("merge adjacent whitespace", function (assert) {
    assert.strictEqual(URLify("D   silent", 8, true), "d-silent");
});

QUnit.test("trim trailing hyphens", function (assert) {
    assert.strictEqual(URLify("D silent always", 9, true), "d-silent");
});

QUnit.test("non-ASCII string", function (assert) {
    assert.strictEqual(URLify("Kaupa-miða", 255, true), "kaupa-miða");
});