d0a66f1701
sorry i ever left you dear mocha node:test has two major issues: * --bail does not work and requires strange modules and incantations. I was able to work around this with a custom module. * the test reporter reports _after_ the suite is run. this makes debugging really hard. the debugs that we print all happen before the test suite summary. poor design overall.
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
import { describe, it, before, after } from 'mocha';
|
|
import BoxError from '../boxerror.js';
|
|
import branding from '../branding.js';
|
|
import common from './common.js';
|
|
import assert from 'node:assert/strict';
|
|
import safe from 'safetydance';
|
|
|
|
|
|
describe('Branding', function () {
|
|
const { setup, cleanup, auditSource } = common;
|
|
|
|
before(setup);
|
|
after(cleanup);
|
|
|
|
it ('can get default cloudron name', async function () {
|
|
const name = await branding.getCloudronName();
|
|
assert.equal(name, 'Cloudron');
|
|
});
|
|
|
|
it('can set name', async function () {
|
|
await branding.setCloudronName('Dolomites', auditSource);
|
|
const name = await branding.getCloudronName();
|
|
assert.equal(name, 'Dolomites');
|
|
});
|
|
|
|
it('can set emoji in name', async function () {
|
|
await branding.setCloudronName('🎊 Cloudron 🎉', auditSource);
|
|
const name = await branding.getCloudronName();
|
|
assert.equal(name, '🎊 Cloudron 🎉');
|
|
});
|
|
|
|
it('cannot set large name', async function () {
|
|
const [error] = await safe(branding.setCloudronName('x'.repeat(65), auditSource));
|
|
assert.equal(error.reason, BoxError.BAD_FIELD);
|
|
});
|
|
|
|
it('can get default cloudron avatar', async function () {
|
|
const avatar = await branding.getCloudronAvatar();
|
|
assert.ok((avatar) instanceof (Buffer));
|
|
});
|
|
|
|
it('can render default footer', async function () {
|
|
assert.ok((await branding.renderFooter()).includes('(https://cloudron.io)'));
|
|
});
|
|
|
|
it('can render footer', async function () {
|
|
await branding.setFooter('BigFoot Inc', auditSource);
|
|
assert.equal(await branding.renderFooter(), 'BigFoot Inc');
|
|
});
|
|
|
|
it('can render footer with YEAR', async function () {
|
|
await branding.setFooter('BigFoot Inc %YEAR%', auditSource);
|
|
assert.equal(await branding.renderFooter(), 'BigFoot Inc 2026');
|
|
});
|
|
});
|