Publish Docker Image / build-and-push (./build/Dockerfile, git.lzstealth.com/lzstealth/pulse-signage-web, web) (push) Successful in 1m15s
Publish Docker Image / build-and-push (./build/Dockerfile.player, git.lzstealth.com/lzstealth/pulse-signage-player, player) (push) Successful in 32s
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
|
|
const {
|
|
buildFontFamilyFormats,
|
|
buildFontStylesheet,
|
|
collectFontLibrarySyncOperations
|
|
} = require('../src/web/lib/media/font-library');
|
|
|
|
test('buildFontFamilyFormats quotes multi-word font families for TinyMCE previews', () => {
|
|
const formats = buildFontFamilyFormats([
|
|
{ family: 'Old London', enabled: true },
|
|
{ family: 'My Custom Font', enabled: true }
|
|
]);
|
|
|
|
assert.match(formats, /Old London='Old London'/);
|
|
assert.match(formats, /My Custom Font='My Custom Font'/);
|
|
assert.match(formats, /Times New Roman='Times New Roman',Times,serif/);
|
|
assert.match(formats, /Lucida Sans Unicode='Lucida Sans Unicode','Lucida Grande',sans-serif/);
|
|
});
|
|
|
|
test('buildFontStylesheet keeps disabled fonts available for rendering', () => {
|
|
const stylesheet = buildFontStylesheet([
|
|
{ family: 'Enabled Font', fileName: 'enabled-font.ttf', format: 'truetype', enabled: true },
|
|
{ family: 'Disabled Font', fileName: 'disabled-font.ttf', format: 'truetype', enabled: false }
|
|
]);
|
|
|
|
assert.match(stylesheet, /Enabled Font/);
|
|
assert.match(stylesheet, /Disabled Font/);
|
|
});
|
|
|
|
test('collectFontLibrarySyncOperations keeps disabled fonts as puts', async () => {
|
|
const tempRoot = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pulse-font-library-'));
|
|
const fontDir = path.join(tempRoot, 'fonts');
|
|
await fs.promises.mkdir(fontDir, { recursive: true });
|
|
await fs.promises.writeFile(path.join(fontDir, 'fonts.json'), JSON.stringify([
|
|
{ family: 'Enabled Font', fileName: 'enabled-font.ttf', enabled: true },
|
|
{ family: 'Disabled Font', fileName: 'disabled-font.ttf', enabled: false }
|
|
], null, 2));
|
|
|
|
const operations = collectFontLibrarySyncOperations(tempRoot);
|
|
const fontOps = operations.filter(function (operation) {
|
|
return String(operation.uploadPath || '').indexOf('/media/fonts/') === 0 && /\.ttf$/.test(String(operation.uploadPath || ''));
|
|
});
|
|
|
|
assert.deepEqual(fontOps.map(function (operation) {
|
|
return operation.type;
|
|
}), ['put', 'put']);
|
|
}); |