How to use inferno-utils - 10 common examples

To help you get started, we’ve selected a few inferno-utils 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 infernojs / inferno / packages / inferno-create-element / __tests__ / hooks.spec.js View on Github external
it('"onComponentWillUnmount" hook should fire, args DOM props', () => {
      const spyObj = {
        fn: () => {}
      };
      const sinonSpy = sinon.spy(spyObj, 'fn');
      const node = template(null, null, spyObj.fn, null, null, null, StatelessComponent)({ a: 1 });
      render(node, container);
      expect(sinonSpy.callCount).toBe(0);
      // do unmount
      render(null, container);

      expect(sinonSpy.callCount).toBe(1);
      expect(sinonSpy.getCall(0).args.length).toBe(2);
      expect(sinonSpy.getCall(0).args[0].outerHTML).toBe(innerHTML('<div>Hello world!</div>'));
      expect(sinonSpy.getCall(0).args[1]).toEqual({ a: 1, children: null });
    });
github infernojs / inferno / packages / inferno-create-element / __tests__ / callback.in.ctr.spec.jsx View on Github external
ConfigsList,
            combineFrom(props, {
              configs: this.state.configs,
              configToChild: {
                customProxyStringRaw: ProxyEditor
              },
              onConfChanged: this.handleModChange
            })
          );
        }
      }

      render(<main>, container);

      // Renders correctly
      expect(innerHTML(container.innerHTML)).toBe(
        innerHTML(
          '<ol><li><input id="customProxyStringRaw" type="checkbox"><label for="customProxyStringRaw">Use proxy? (click this)</label><div></div></li><li><input id="This one is needed for reproduction too!" type="checkbox"><label for="This one is needed for reproduction too!">needed too</label><div></div></li></ol>'
        )
      );

      let checkBoxes = container.querySelectorAll('input');

      expect(checkBoxes.length).toBe(2);

      expect(checkBoxes[0].checked).toBe(false);
      expect(checkBoxes[1].checked).toBe(false);

      checkBoxes[0].click(); // Click first checkbox
      rerender();
      checkBoxes = container.querySelectorAll('input');
</main>
github infernojs / inferno / packages / inferno-compat / __tests__ / styles.spec.jsx View on Github external
it('Should be possible to use camelCase styles when reactStyles support is on', () =&gt; {
    render(<div style="{{">Test</div>, container);

    expect(innerHTML(container.innerHTML)).toBe(innerHTML(`<div style="background-color: red;">Test</div>`));
  });
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render element with a text string', function() {
      const element = createElement('div', null, 'body text');
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div>body text</div>'));
    });
github infernojs / inferno / packages / inferno-create-element / __tests__ / update.ext.spec.js View on Github external
it('should insert an additional tag node', () =&gt; {
    const template = child =&gt; createElement('div', null, child);
    const div = () =&gt; createElement('div', null);

    render(template(null), container);
    expect(container.firstChild.innerHTML).toBe('');
    render(template(div()), container);
    expect(container.firstChild.innerHTML).toBe(innerHTML('<div></div>'));
  });
github infernojs / inferno / packages / inferno-create-element / __tests__ / update.ext.spec.js View on Github external
it('should insert an additional tag node', () =&gt; {
    const template = child =&gt; createElement('div', null, child);
    const span = () =&gt; createElement('span', null);

    render(template(span()), container);
    expect(container.firstChild.innerHTML).toBe(innerHTML('<span></span>'));
    render(template(null), container);
    expect(container.firstChild.innerHTML).toBe('');
    render(template(span()), container);
    expect(container.firstChild.innerHTML).toBe(innerHTML('<span></span>'));
  });
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render a string div', () =&gt; {
      const Div = 'div';
      render(<div>Hello World</div>, container);
      expect(container.innerHTML).toBe(innerHTML('<div>Hello World</div>'));
    });
  });
github infernojs / inferno / packages / inferno-create-element / __tests__ / update.ext.spec.js View on Github external
it('should patch a text node into a tag node', () =&gt; {
    const template = child =&gt; createElement('div', null, child);
    const span = function() {
      return 'Hello';
    };

    render(template(span()), container);
    expect(container.innerHTML).toBe(innerHTML('<div>Hello</div>'));
  });
github infernojs / inferno / packages / inferno-server / __tests__ / hydration-ext.spec.server.jsx View on Github external
it('Should hydrate correctly when CSR component returns null', () =&gt; {
    const container = createContainerWithHTML('<div></div>');

    hydrate(
      <div>
        
          
        
      </div>,
      container
    );

    expect(innerHTML(container.innerHTML)).toEqual(innerHTML('<div></div>'));
  });
github infernojs / inferno / packages / inferno-server / __tests__ / hydration-ext.spec.server.jsx View on Github external
it('Should hydrate correctly when CSR children is missing', () =&gt; {
    const container = createContainerWithHTML('<div> </div>');

    hydrate(
      
        
          
        
      ,
      container
    );

    expect(innerHTML(container.innerHTML)).toEqual(innerHTML(compHtml2));
  });

inferno-utils

常用方法

ISC
Latest version published 7 years ago

Package Health Score

40 / 100
Full package analysis

Popular inferno-utils functions

Similar packages