How to use the fusion-core.consumeSanitizedHTML function in fusion-core

To help you get started, we’ve selected a few fusion-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fusionjs / fusionjs / fusion-plugin-i18n / src / __tests__ / index.node.js View on Github external
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();
});
github fusionjs / fusionjs / fusion-plugin-react-redux / src / __tests__ / index.node.js View on Github external
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();
});
github fusionjs / fusionjs / create-fusion-plugin / templates / plugin / content / src / __tests__ / index.node.js View on Github external
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();
});
github fusionjs / fusionjs / fusion-plugin-i18n / src / __tests__ / index.node.js View on Github external
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();
});
github fusionjs / fusionjs / fusion-plugin-error-handling / src / __tests__ / index.node.js View on Github external
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(/
github fusionjs / fusionjs / fusion-plugin-styletron-react / src / __tests__ / index.node.js View on Github external
push(h) {
          t.equal(
            consumeSanitizedHTML(h),
            '<style class="_styletron_hydrate_">.ae{background-color:silver}.af{color:red}</style>',
            'Pushes generated styles to head'
          );
        },
      },