Update integration row tests for host bylines
This commit is contained in:
1 parent
3909bd402a
commit
a465fba333
3 files changed
+74
-29
No files matched your search
@@ -360,8 +360,36 @@ module('Unit | Service | integrations', function (hooks) {
|
||||
const row = service.rows.find(
|
||||
(entry) => entry.id === 'homeassistant-ha.example.com:8123'
|
||||
);
|
||||
assert.strictEqual(row.label, 'Home');
|
||||
assert.strictEqual(row.byline, 'ha.example.com:8123');
|
||||
assert.strictEqual(row.label, 'Home Assistant');
|
||||
assert.strictEqual(row.byline, 'Home');
|
||||
});
|
||||
|
||||
test('homeassistant falls back to the host byline without a custom name', function (assert) {
|
||||
const sites = new FakeSitesService();
|
||||
sites.all = [
|
||||
{
|
||||
id: 'homeassistant-ha.example.com:8123',
|
||||
type: 'homeassistant',
|
||||
label: 'ha.example.com:8123',
|
||||
href: 'https://ha.example.com:8123/',
|
||||
},
|
||||
];
|
||||
sites.records = {
|
||||
'homeassistant-ha.example.com:8123': {
|
||||
url: 'https://ha.example.com:8123',
|
||||
token: 'token-a',
|
||||
},
|
||||
};
|
||||
|
||||
register(this.owner, { sites });
|
||||
|
||||
const service = this.owner.lookup('service:integrations');
|
||||
const row = service.rows.find(
|
||||
(entry) => entry.id === 'homeassistant-ha.example.com:8123'
|
||||
);
|
||||
|
||||
assert.strictEqual(row.label, 'Home Assistant');
|
||||
assert.strictEqual(row.byline, 'ha.example.com');
|
||||
});
|
||||
|
||||
test('calendar adapters expose instances and remove', async function (assert) {
|
||||
@@ -403,6 +431,18 @@ module('Unit | Service | integrations', function (hooks) {
|
||||
assert.strictEqual(ics.instances.length, 1);
|
||||
assert.strictEqual(ics.instances[0].label, 'Holidays');
|
||||
|
||||
const caldavRow = service.rows.find(
|
||||
(entry) => entry.id === 'calendar-caldav-cal.example.com-alice'
|
||||
);
|
||||
assert.strictEqual(caldavRow.label, 'CalDAV');
|
||||
assert.strictEqual(caldavRow.byline, 'cal.example.com');
|
||||
|
||||
const icsRow = service.rows.find(
|
||||
(entry) => entry.id === 'calendar-ics-example.org'
|
||||
);
|
||||
assert.strictEqual(icsRow.label, 'ICS / WebCal');
|
||||
assert.strictEqual(icsRow.byline, 'example.org');
|
||||
|
||||
await service.remove({
|
||||
type: 'calendar-caldav',
|
||||
id: 'calendar-caldav-cal.example.com-alice',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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(''), '');
|
||||
});
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { displayUrl } from 'dashtab/utils/display-url';
|
||||
|
||||
module('Unit | Utility | display-url', function () {
|
||||
test('strips the https scheme', function (assert) {
|
||||
assert.strictEqual(
|
||||
displayUrl('https://forum.example.com'),
|
||||
'forum.example.com'
|
||||
);
|
||||
});
|
||||
|
||||
test('strips the http scheme', function (assert) {
|
||||
assert.strictEqual(
|
||||
displayUrl('http://forum.example.com'),
|
||||
'forum.example.com'
|
||||
);
|
||||
});
|
||||
|
||||
test('leaves a scheme-less value untouched', function (assert) {
|
||||
assert.strictEqual(displayUrl('forum.example.com'), 'forum.example.com');
|
||||
});
|
||||
|
||||
test('returns an empty string for missing values', function (assert) {
|
||||
assert.strictEqual(displayUrl(undefined), '');
|
||||
assert.strictEqual(displayUrl(null), '');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user