How to use the @ephox/agar.Chain.async function in @ephox/agar

To help you get started, we’ve selected a few @ephox/agar 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 tinymce / tinymce-angular / tinymce-angular-component / src / editor / editor.component.spec.ts View on Github external
UnitTest.asynctest('NgModelTest', (success, failure) => {
  const createComponent = (componentType: Type) => {
    TestBed.configureTestingModule({
      imports: [EditorModule, FormsModule],
      declarations: [componentType]
    }).compileComponents();
    return TestBed.createComponent(componentType);
  };

  const fakeKeyUp = (editor: any, char: string) => {
    editor.selection.setContent(char);
    editor.fire('keyup');
  };

  const cSetup = Chain.async((_, next) => {
    const fixture = createComponent(EditorWithNgModelComponent);
    fixture.detectChanges();
    const editorDebugElement = fixture.debugElement.query(By.directive(EditorComponent));
    const ngModel = editorDebugElement.injector.get(NgModel);
    const editorComponent = editorDebugElement.componentInstance;

    editorComponent.onInit.subscribe(() => {
      editorComponent.editor.on('SkinLoaded', () => {
        setTimeout(() => {
          next({ fixture, editorDebugElement, editorComponent, ngModel });
        }, 0);
      });
    });
  });

  const cTeardown = Chain.op(() => {
github tinymce / tinymce-react / src / alien / Loader.tsx View on Github external
const cSetup = (createElement: (Ed: TestEditor) => JSX.Element) => {
  return Chain.async((_, next, die) => {
    const root = document.createElement('div');
    document.body.append(root);

    const onEditorLoaded: OnEditorLoaded = (editor, ref) => {
      Option.from(ref.current)
        .map(ReactDOM.findDOMNode)
        .filter((val) => val instanceof Element)
        .fold(() => die('Could not find DOMNode'), (DOMNode) => {
          next({
            ref,
            root,
            editor,
            DOMNode: DOMNode as Element
          });
        });
    };