2021-05-22 07:46:47 -05:00
|
|
|
import renderTemplate from '../../../../src/api/web/html/template';
|
2021-03-29 05:32:37 -05:00
|
|
|
|
|
|
|
const manifest = require('./partials/manifest/manifest.json');
|
|
|
|
|
|
|
|
const exampleManifest = {
|
|
|
|
css: ['main.css'],
|
|
|
|
js: ['runtime.js', 'main.js'],
|
|
|
|
ico: '/static/foo.ico',
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('template', () => {
|
|
|
|
test('custom render', () => {
|
2021-05-22 07:46:47 -05:00
|
|
|
expect(renderTemplate({ options: { base: 'http://domain.com' }, manifest: exampleManifest }, manifest)).toMatchSnapshot();
|
2021-03-29 05:32:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('custom title', () => {
|
2021-05-22 07:46:47 -05:00
|
|
|
expect(renderTemplate({ options: { base: 'http://domain.com', title: 'foo title' }, manifest: exampleManifest }, manifest)).toMatchSnapshot();
|
2021-03-29 05:32:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('custom title', () => {
|
2021-05-22 07:46:47 -05:00
|
|
|
expect(renderTemplate({ options: { base: 'http://domain.com', title: 'foo title' }, manifest: exampleManifest }, manifest)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('custom logo', () => {
|
|
|
|
expect(renderTemplate({ options: { base: 'http://domain.com', logo: 'http://domain/logo.png' }, manifest: exampleManifest }, manifest)).toMatchSnapshot();
|
2021-03-29 05:32:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('meta scripts', () => {
|
|
|
|
expect(
|
2021-05-22 07:46:47 -05:00
|
|
|
renderTemplate({ options: { base: 'http://domain.com' }, metaScripts: [`<style>.someclass{font-size:10px;}</style>`], manifest: exampleManifest }, manifest)
|
2021-03-29 05:32:37 -05:00
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('custom body after', () => {
|
2021-05-22 07:46:47 -05:00
|
|
|
expect(renderTemplate({ options: { base: 'http://domain.com' }, scriptsBodyAfter: [`<script src="foo"/>`], manifest: exampleManifest }, manifest)).toMatchSnapshot();
|
2021-03-29 05:32:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('custom body before', () => {
|
|
|
|
expect(
|
|
|
|
renderTemplate(
|
|
|
|
{
|
2021-05-22 07:46:47 -05:00
|
|
|
options: { base: 'http://domain.com' },
|
2021-03-29 05:32:37 -05:00
|
|
|
scriptsbodyBefore: [`<script src="fooBefore"/>`, `<script src="barBefore"/>`],
|
|
|
|
manifest: exampleManifest,
|
|
|
|
},
|
|
|
|
manifest
|
|
|
|
)
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|