mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-29 04:03:08 +02:00
1f7a81aae7
* update deps
* node16
* wip
* wip
* wip
* Update test-utils.ts
* wip
* Update tsconfig.json
* wip
* Update package.json
* wip
* Update following.vue
* Update followers.vue
* Update index.vue
* Update share.vue
* Update MkUserPopup.vue
* Update MkPostForm.vue
* wip
* Update MkTokenGenerateWindow.vue
* Update MkPagination.vue
* refactor
* update deps
* update deps
* Update sw.ts
* wip
* wip
* wip
* Update FetchInstanceMetadataService.ts
* Update FetchInstanceMetadataService.ts
* update node
* update deps
* 🎨
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { describe, test, assert, afterEach } from 'vitest';
|
|
import { render, cleanup, type RenderResult } from '@testing-library/vue';
|
|
import './init';
|
|
import type * as Misskey from 'misskey-js';
|
|
import { directives } from '@/directives';
|
|
import { components } from '@/components/index';
|
|
import XHome from '@/pages/user/home.vue';
|
|
|
|
describe('XHome', () => {
|
|
const renderHome = (user: Partial<Misskey.entities.UserDetailed>): RenderResult => {
|
|
return render(XHome, {
|
|
props: { user, disableNotes: true },
|
|
global: { directives, components },
|
|
});
|
|
};
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
test('Should render the remote caution when user.host exists', async () => {
|
|
const home = renderHome({
|
|
id: 'blobcat',
|
|
name: 'blobcat',
|
|
host: 'example.com',
|
|
uri: 'https://example.com/@user',
|
|
url: 'https://example.com/@user/profile',
|
|
roles: [],
|
|
createdAt: '1970-01-01T00:00:00.000Z',
|
|
fields: [],
|
|
pinnedNotes: [],
|
|
});
|
|
|
|
const anchor = home.container.querySelector<HTMLAnchorElement>('a[href^="https://example.com/"]');
|
|
assert.exists(anchor, 'anchor to the remote exists');
|
|
assert.strictEqual(anchor?.href, 'https://example.com/@user/profile');
|
|
|
|
assert.ok(anchor?.parentElement?.classList.contains('warn'), 'the parent is a warning');
|
|
});
|
|
|
|
test('The remote caution should fall back to uri if url is null', async () => {
|
|
const home = renderHome({
|
|
id: 'blobcat',
|
|
name: 'blobcat',
|
|
host: 'example.com',
|
|
uri: 'https://example.com/@user',
|
|
url: null,
|
|
roles: [],
|
|
createdAt: '1970-01-01T00:00:00.000Z',
|
|
fields: [],
|
|
pinnedNotes: [],
|
|
});
|
|
|
|
const anchor = home.container.querySelector<HTMLAnchorElement>('a[href^="https://example.com/"]');
|
|
assert.exists(anchor, 'anchor to the remote exists');
|
|
assert.strictEqual(anchor?.href, 'https://example.com/@user');
|
|
});
|
|
});
|