All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
/**
|
|
* Renderer Runner — renderer/contract suite
|
|
*
|
|
* Tests the sw.renderers registry contract.
|
|
* Requires mermaid-renderer to be installed and loaded.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
sw.testing.suite('renderer/contract', async function (s) {
|
|
|
|
s.test('sw.renderers exists', async function (t) {
|
|
t.assert.ok(sw.renderers, 'sw.renderers is defined');
|
|
t.assert.ok(typeof sw.renderers.register === 'function', 'register is a function');
|
|
t.assert.ok(typeof sw.renderers.list === 'function', 'list is a function');
|
|
t.assert.ok(typeof sw.renderers.runBlockRenderers === 'function', 'runBlockRenderers is a function');
|
|
t.assert.ok(typeof sw.renderers.runPostRenderers === 'function', 'runPostRenderers is a function');
|
|
});
|
|
|
|
s.test('mermaid renderer registered', async function (t) {
|
|
var info = sw.renderers.list();
|
|
t.assert.ok(info.block, 'block renderers list exists');
|
|
t.assert.ok(Array.isArray(info.block), 'block is array');
|
|
var mermaid = info.block.find(function (r) { return r.name === 'mermaid'; });
|
|
if (!mermaid) {
|
|
t.warn('Mermaid renderer not found in block list — extension may not have loaded yet');
|
|
return;
|
|
}
|
|
t.assert.ok(mermaid, 'mermaid renderer found');
|
|
t.assert.eq(mermaid.pattern, 'mermaid', 'pattern matches "mermaid"');
|
|
});
|
|
|
|
s.test('block renderer match', async function (t) {
|
|
// Test that runBlockRenderers returns true for 'mermaid' lang
|
|
// We need a container element for the render call
|
|
t.browserOnly(function () {
|
|
var container = document.createElement('div');
|
|
var handled = sw.renderers.runBlockRenderers('mermaid', 'graph LR; A-->B', container);
|
|
t.assert.ok(handled, 'mermaid block was handled by a renderer');
|
|
});
|
|
});
|
|
|
|
s.test('unmatched block returns false', async function (t) {
|
|
t.browserOnly(function () {
|
|
var container = document.createElement('div');
|
|
var handled = sw.renderers.runBlockRenderers('nonexistent-lang-xyz', 'code', container);
|
|
t.assert.eq(handled, false, 'unmatched lang returns false');
|
|
});
|
|
});
|
|
});
|
|
})();
|