Release v2.5.6
This commit is contained in:
+62
-4
@@ -1,14 +1,28 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { createQrCodeSvg, buildQrCodeContent } = require('../src/data/qr-code');
|
||||
const { createQrCodeSvg, createStyledQrCodeSvg, createStyledQrCodeDataUrl, buildQrCodeContent } = require('../src/data/qr-code');
|
||||
const { buildSlidePayload } = require('../src/data/slides');
|
||||
|
||||
test('createQrCodeSvg renders a qr svg for non-empty values', async () => {
|
||||
const svg = await createQrCodeSvg('https://example.com');
|
||||
|
||||
assert.equal(typeof svg, 'string');
|
||||
assert.match(svg, /^<svg[\s>]/);
|
||||
assert.match(svg, /<svg[\s>]/);
|
||||
});
|
||||
|
||||
test('createStyledQrCodeSvg renders a styled qr svg for non-empty values', async () => {
|
||||
const svg = await createStyledQrCodeSvg('https://example.com');
|
||||
|
||||
assert.equal(typeof svg, 'string');
|
||||
assert.match(svg, /<svg[\s>]/);
|
||||
});
|
||||
|
||||
test('createStyledQrCodeDataUrl renders a styled qr data url for non-empty values', async () => {
|
||||
const dataUrl = await createStyledQrCodeDataUrl('https://example.com');
|
||||
|
||||
assert.equal(typeof dataUrl, 'string');
|
||||
assert.match(dataUrl, /^data:image\/svg\+xml/);
|
||||
});
|
||||
|
||||
test('buildQrCodeContent stores qr svg content for qr-code regions', async () => {
|
||||
@@ -17,7 +31,9 @@ test('buildQrCodeContent stores qr svg content for qr-code regions', async () =>
|
||||
assert.equal(content.type, 'qr-code');
|
||||
assert.equal(content.value, 'https://example.com');
|
||||
assert.equal(typeof content.qr_svg, 'string');
|
||||
assert.match(content.qr_svg, /^<svg[\s>]/);
|
||||
assert.match(content.qr_svg, /<svg[\s>]/);
|
||||
assert.equal(typeof content.qr_preview, 'string');
|
||||
assert.match(content.qr_preview, /^data:image\/svg\+xml/);
|
||||
});
|
||||
|
||||
test('buildSlidePayload stores qr-code slide content from the submitted url', async () => {
|
||||
@@ -31,6 +47,10 @@ test('buildSlidePayload stores qr-code slide content from the submitted url', as
|
||||
return [[{ id: 22, template_id: 7, region_key: 'qrRegion', region_type: 'qr-code', label: 'QR' }]];
|
||||
}
|
||||
|
||||
if (sql.includes('FROM i_rss_feed_items')) {
|
||||
return [[{ count: 2 }]];
|
||||
}
|
||||
|
||||
return [[]];
|
||||
}
|
||||
};
|
||||
@@ -48,5 +68,43 @@ test('buildSlidePayload stores qr-code slide content from the submitted url', as
|
||||
assert.equal(content.qrRegion.type, 'qr-code');
|
||||
assert.equal(content.qrRegion.value, 'https://example.com');
|
||||
assert.equal(typeof content.qrRegion.qr_svg, 'string');
|
||||
assert.match(content.qrRegion.qr_svg, /^<svg[\s>]/);
|
||||
assert.match(content.qrRegion.qr_svg, /<svg[\s>]/);
|
||||
assert.equal(typeof content.qrRegion.qr_preview, 'string');
|
||||
assert.match(content.qrRegion.qr_preview, /^data:image\/svg\+xml/);
|
||||
});
|
||||
|
||||
test('buildSlidePayload clamps rss item_number to the available item count', async () => {
|
||||
const pool = {
|
||||
async query(sql) {
|
||||
if (sql.includes('FROM c_templates st')) {
|
||||
return [[{ id: 8, name: 'Template 8', canvas_size_id: 1, canvas_size_width: 1920, canvas_size_height: 1080 }]];
|
||||
}
|
||||
|
||||
if (sql.includes('FROM c_template_regions')) {
|
||||
return [[{ id: 23, template_id: 8, region_key: 'rssRegion', region_type: 'rss', label: 'RSS' }]];
|
||||
}
|
||||
|
||||
if (sql.includes('FROM i_rss_feed_items')) {
|
||||
return [[{ count: 2 }]];
|
||||
}
|
||||
|
||||
return [[]];
|
||||
}
|
||||
};
|
||||
|
||||
const payload = await buildSlidePayload(pool, {
|
||||
body: {
|
||||
title: 'RSS Slide',
|
||||
template_id: '8',
|
||||
region_rss_feed_id_23: '11',
|
||||
region_rss_item_number_23: '5',
|
||||
region_text_23: '<p>Hello</p>'
|
||||
},
|
||||
files: []
|
||||
}, null);
|
||||
|
||||
const content = JSON.parse(payload.contentJson);
|
||||
assert.equal(content.rssRegion.type, 'rss');
|
||||
assert.equal(content.rssRegion.feed_id, 11);
|
||||
assert.equal(content.rssRegion.item_number, 2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user