Files
cinny/src/swShare.test.ts
T

28 lines
885 B
TypeScript
Raw Normal View History

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { shareDraftText } from './swShare';
const base = { files: [], receivedAt: 0 };
test('shareDraftText joins title, text and url', () => {
assert.equal(
shareDraftText({ ...base, title: 'A page', text: 'look at this', url: 'https://x.test/p' }),
'A page\nlook at this\nhttps://x.test/p',
);
});
test('shareDraftText drops a title/url the text already contains', () => {
assert.equal(
shareDraftText({
...base,
title: 'A page',
text: 'A page https://x.test/p',
url: 'https://x.test/p',
}),
'A page https://x.test/p',
);
assert.equal(shareDraftText({ ...base, text: 'from the share sheet' }), 'from the share sheet');
assert.equal(shareDraftText({ ...base, url: 'https://x.test' }), 'https://x.test');
assert.equal(shareDraftText(base), '');
});