33 lines
984 B
JavaScript
33 lines
984 B
JavaScript
import { module, test } from 'qunit';
|
|
import { displayHost } from 'dashtab/utils/display-host';
|
|
|
|
module('Unit | Utility | display-host', function () {
|
|
test('returns the hostname without the scheme or path', function (assert) {
|
|
assert.strictEqual(
|
|
displayHost('https://cal.example.com/dav/'),
|
|
'cal.example.com'
|
|
);
|
|
assert.strictEqual(
|
|
displayHost('http://forum.example.com'),
|
|
'forum.example.com'
|
|
);
|
|
});
|
|
|
|
test('drops the port', function (assert) {
|
|
assert.strictEqual(
|
|
displayHost('https://ha.example.com:8123'),
|
|
'ha.example.com'
|
|
);
|
|
});
|
|
|
|
test('accepts a scheme-less value', function (assert) {
|
|
assert.strictEqual(displayHost('forum.example.com'), 'forum.example.com');
|
|
});
|
|
|
|
test('returns an empty string for missing or invalid values', function (assert) {
|
|
assert.strictEqual(displayHost(undefined), '');
|
|
assert.strictEqual(displayHost(null), '');
|
|
assert.strictEqual(displayHost(''), '');
|
|
});
|
|
});
|