This is the child article of ReactTestUtils - Tutorial. In this article, I will explain how to Check Component or Element Type. Here we can verify

Verify DOM Component

General HTML components are DOM Components. It can be verified with isDOMComponent function. Below example finds element with h1 tag. isDOMComponent function returns true 
it('Verify Dom Component', function () {
    var root = TestUtils.renderIntoDocument(<Root/>);
    var rootElm = TestUtils.findRenderedDOMComponentWithTag(root, 'h1');
    expect(TestUtils.isElement(rootElm)).toEqual(false);
    expect(TestUtils.isDOMComponent(rootElm)).toEqual(true);
    expect(TestUtils.isCompositeComponent(rootElm)).toEqual(false);
});

Verify Composite Component

User defined React element is Composite component. Here SubRoot is user defined React element, It can be verified using isCompositeComponent
it('Verify Composite Type', function () {
    var root = TestUtils.renderIntoDocument(<Root/>);
    var rootElm = TestUtils.findRenderedComponentWithType(root, SubRoot);

    expect(TestUtils.isElement(rootElm)).toEqual(false);
    expect(TestUtils.isDOMComponent(rootElm)).toEqual(false);

    expect(TestUtils.isCompositeComponent(rootElm)).toEqual(true);
    expect(TestUtils.isCompositeComponentWithType(rootElm, SubRoot)).toEqual(true);
});

9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Very interesting and helpful sharing, thank you very much.Street View Online

    ReplyDelete
  3. Using the online service https://topessaybrands.com/review/ewriters-pro-review/ I do all the writing assignments and it helps me a lot in my learning and getting good grades. I, too, do not lose trust from the teachers and my reputation has become much better.

    ReplyDelete
  4. Such an impressive article with points that for sure will be coming in handy. Make sure to check the link below:
    buy logo online

    ReplyDelete
  5. I am very happy after visiting your website with very useful information. I am from one of the digital marketing agency... To visit my agency click on link Visitdigitalguru

    ReplyDelete
  6. Online casinos are played through a computer screen, mouse and keyboard while offline casinos are played in a physical building https://baccarat.team/ with physical cards, wheels and tables all around you. Until virtual reality gets to the point where it can rival real life, the unfortunate truth of the matter is that online casinos are going to carry this disadvantage for a very long time.

    ReplyDelete
  7. Online gambling has gained popularity to a large crowd, https://blackjackup.com/software/ that’s no secret. One of the reasons, however, is due to the free casino games offered to players.

    ReplyDelete
  8. Although each one of the online casinos will run the way it chooses, livedealers.team most of them do offer you special features which will enhance your gaming experience. Some of the features will allow you to view the games from different angles, change things about the environment, use autoplay so the game plays itself, or many other features.

    ReplyDelete
  9. It's useful for me, thanks for sharing it with us,

    law dissertation Writers

    ReplyDelete

Blogroll

Popular Posts