Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return;
}
const i18n = I18n.provides(deps);
if (!I18n.middleware) {
t.end();
return;
}
await I18n.middleware(deps, i18n)(ctx, () => Promise.resolve());
t.equals(ctx.template.body.length, 1, 'injects hydration code');
t.equals(
// $FlowFixMe
consumeSanitizedHTML(ctx.template.body[0]).match('hello')[0],
'hello'
);
t.equals(consumeSanitizedHTML(ctx.template.body[0]).match(''), null);
t.equals(ctx.template.htmlAttrs['lang'], 'en-US');
chunkTranslationMap.dispose('a.js', [0], Object.keys(data));
chunkTranslationMap.translations.clear();
t.end();
});
const Plugin = getService(appCreator(reducer), Redux);
t.plan(5);
if (!Redux.middleware) {
t.end();
return;
}
// $FlowFixMe
await Redux.middleware(null, Plugin)(ctx, () => Promise.resolve());
t.ok(Plugin.from(ctx).store);
t.notEquals(ctx.element, element, 'wraps provider');
t.equals(ctx.template.body.length, 1, 'pushes serialization to body');
// $FlowFixMe
t.equals(consumeSanitizedHTML(ctx.template.body[0]).match('test')[0], 'test');
t.equals(consumeSanitizedHTML(ctx.template.body[0]).match(''), null);
t.end();
});
const ctx: any = {element, template: {body: []}, memoized: new Map()};
const service = getService(appCreator(), Plugin);
t.plan(3);
if (!Plugin.middleware) {
t.end();
return;
}
// $FlowFixMe
await Plugin.middleware(null, service)(ctx, () => Promise.resolve());
t.equals(ctx.template.body.length, 1, 'pushes serialization to body');
t.equals(
// $FlowFixMe
consumeSanitizedHTML(ctx.template.body[0]).match('__plugin__value__')[0],
'__plugin__value__'
);
t.equals(consumeSanitizedHTML(ctx.template.body[0]).match(''), null);
t.end();
});
t.plan(4);
if (!I18n.provides) {
t.end();
return;
}
const i18n = I18n.provides(deps);
if (!I18n.middleware) {
t.end();
return;
}
await I18n.middleware(deps, i18n)(ctx, () => Promise.resolve());
t.equals(ctx.template.body.length, 1, 'injects hydration code');
t.equals(
// $FlowFixMe
consumeSanitizedHTML(ctx.template.body[0]).match('hello')[0],
'hello'
);
t.equals(consumeSanitizedHTML(ctx.template.body[0]).match(''), null);
t.equals(ctx.template.htmlAttrs['lang'], 'en-US');
chunkTranslationMap.dispose('a.js', [0], Object.keys(data));
chunkTranslationMap.translations.clear();
t.end();
});
test('adds script', async t => {
const app = new App('test', el => el);
app.register(ErrorHandling);
app.register(ErrorHandlerToken, () => {});
const ctx = await await getSimulator(app).render('/');
t.ok(
consumeSanitizedHTML(ctx.template.head[0]).match(/
ctx.template.head.map(e => consumeSanitizedHTML(e)).join('')
);
push(h) {
t.equal(
consumeSanitizedHTML(h),
'<style class="_styletron_hydrate_">.ae{background-color:silver}.af{color:red}</style>',
'Pushes generated styles to head'
);
},
},