tests: add footer tests
This commit is contained in:
@@ -131,7 +131,6 @@ async function add(domain, data, auditSource) {
|
||||
if (domain.endsWith('.')) throw new BoxError(BoxError.BAD_FIELD, 'Invalid domain', { field: 'domain' });
|
||||
|
||||
if (zoneName) {
|
||||
console.log('THE ZONE', zoneName);
|
||||
if (!tld.isValid(zoneName)) throw new BoxError(BoxError.BAD_FIELD, 'Invalid zoneName', { field: 'zoneName' });
|
||||
if (zoneName.endsWith('.')) throw new BoxError(BoxError.BAD_FIELD, 'Invalid zoneName', { field: 'zoneName' });
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
/* global after:false */
|
||||
|
||||
const common = require('./common.js'),
|
||||
constants = require('../../constants.js'),
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
paths = require('../../paths.js'),
|
||||
@@ -166,4 +167,38 @@ describe('Branding API', function () {
|
||||
expect(response.body.blacklist).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('footer', function () {
|
||||
it('get default succeeds', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.footer).to.eql(constants.FOOTER);
|
||||
});
|
||||
|
||||
it('cannot set without data', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/branding/footer`)
|
||||
.query({ access_token: owner.token })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('set succeeds', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/branding/footer`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ footer: 'BigFoot Inc' });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
});
|
||||
|
||||
it('get succeeds', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/branding/footer`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.footer).to.eql('BigFoot Inc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ const SETTINGS_FIELDS = [ 'name', 'value' ].join(',');
|
||||
const SETTINGS_BLOB_FIELDS = [ 'name', 'valueBlob' ].join(',');
|
||||
|
||||
const gDefaults = (function () {
|
||||
var result = { };
|
||||
const result = { };
|
||||
result[exports.AUTOUPDATE_PATTERN_KEY] = cron.DEFAULT_AUTOUPDATE_PATTERN;
|
||||
result[exports.TIME_ZONE_KEY] = 'America/Los_Angeles';
|
||||
result[exports.CLOUDRON_NAME_KEY] = 'Cloudron';
|
||||
@@ -207,7 +207,7 @@ const gDefaults = (function () {
|
||||
submitTickets: true
|
||||
};
|
||||
|
||||
result[exports.FOOTER_KEY] = '';
|
||||
result[exports.FOOTER_KEY] = constants.FOOTER;
|
||||
|
||||
return result;
|
||||
})();
|
||||
|
||||
30
src/test/branding-test.js
Normal file
30
src/test/branding-test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/* global it:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
const branding = require('../branding.js'),
|
||||
common = require('./common.js'),
|
||||
constants = require('../constants.js'),
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('Branding', function () {
|
||||
const { setup, cleanup } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
it('can render default footer', async function () {
|
||||
expect(branding.renderFooter(constants.FOOTER)).to.contain('(https://cloudron.io)');
|
||||
});
|
||||
|
||||
it('can render footer', async function () {
|
||||
expect(branding.renderFooter('BigFoot Inc')).to.be('BigFoot Inc');
|
||||
});
|
||||
|
||||
it('can render footer with YEAR', async function () {
|
||||
expect(branding.renderFooter('BigFoot Inc %YEAR%')).to.be('BigFoot Inc 2021');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user