一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
47 行
1.9 KiB
TypeScript
47 行
1.9 KiB
TypeScript
import { extractOpenGraphTags, OpenGraphTags } from './openGraph';
|
|
import { tempFilePath } from '@joplin/lib/testing/test-utils';
|
|
import { writeFile } from 'fs-extra';
|
|
|
|
describe('openGraph', () => {
|
|
|
|
it('should extract the Open Graph tags', async () => {
|
|
const tests: [string, OpenGraphTags][] = [
|
|
|
|
['# My title\n\nMy note description **with bold text**', {
|
|
title: 'My title',
|
|
description: 'My note description with bold text',
|
|
url: 'https://test.com',
|
|
}],
|
|
|
|
['# My very very very very very very very very very very very very long title\n\nMy description that is over 200 characters. My description that is over 200 characters. My description that is over 200 characters. My description that is over 200 characters. My description that is over 200 characters.', {
|
|
title: 'My very very very very very very very very very very very very long...',
|
|
description: 'My description that is over 200 characters. My description that is over 200 characters. My description that is over 200 characters. My description that is over 200 characters. My description that i...',
|
|
url: 'https://test.com',
|
|
}],
|
|
|
|
['# Page with an image\n\nSome text followed by an image.  ', {
|
|
title: 'Page with an image',
|
|
description: 'Some text followed by an image.',
|
|
url: 'https://test.com',
|
|
image: 'https://test.com/hello1.png',
|
|
}],
|
|
|
|
['# Image without domain\n\n', {
|
|
title: 'Image without domain',
|
|
description: '',
|
|
url: 'https://test.com',
|
|
image: 'https://joplinapp.org/hello1.png',
|
|
}],
|
|
];
|
|
|
|
for (const test of tests) {
|
|
const [input, expected] = test;
|
|
const filePath = await tempFilePath('md');
|
|
await writeFile(filePath, input);
|
|
const actual = await extractOpenGraphTags(filePath, 'https://test.com');
|
|
expect(actual).toEqual(expected);
|
|
}
|
|
});
|
|
|
|
});
|