Files
memind/mindspace-public-share-widget.test.mjs

21 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

import test from 'node:test';
import assert from 'node:assert/strict';
import { injectPublicFileShareButton } from './mindspace-public-share-widget.mjs';
test('injectPublicFileShareButton adds plaza entry and confirm dialog', () => {
const result = injectPublicFileShareButton('<!doctype html><html><body><h1>Hi</h1></body></html>');
assert.match(result.html, /data-action="plaza"/);
assert.match(result.html, /发布到 Plaza/);
assert.match(result.html, /data-action="plaza-confirm"/);
assert.match(result.html, /quick-plaza-from-public-html/);
assert.match(result.html, /quick-plaza-from-public-html\/status/);
assert.match(result.html, /data-plaza-view="already"/);
assert.match(result.html, /已在广场发布/);
assert.match(result.html, /data-mindspace-public-share-dialog-panel role="dialog"/);
assert.doesNotMatch(result.html, /data-mindspace-public-share-dialog-panel"/);
assert.match(result.html, /color:#fff !important/);
assert.match(result.html, /apiErrorBody/);
assert.match(result.html, /ALREADY_PUBLISHED/);
assert.equal(result.scriptHashes.length, 1);
});