React-table: Testing utilities

Created on 9 Feb 2017  路  4Comments  路  Source: tannerlinsley/react-table

I could not find any automated tests (with jest, mocha, jasmine and the like). Are there none? And if no, is it planned to have some in the future, or how is the testing done in this project?

Everything else looks promising so far :)

Most helpful comment

This should be reconsidered. Tests should not be optional.

All 4 comments

There are still no tests written 馃槶 . But I would love to get started on it. The library is only a couple weeks old still, but the API is starting to settle down enough that I would feel good about getting some tests in there for some of the business logic like:

  • Column creation
  • Sorting
  • Data accessors

I would still be worried about getting to invested into the the display logic right now. Maybe we can just implement some generic snapshot testing for that?

Also, I would definitely let you spearhead it if you want :) I'm always looking for contributors and help!

Closing for now.

This should be reconsidered. Tests should not be optional.

I've been writing tests around ReactTable and I've run into an issue with testing any of the following using Jest/Enzyme. The problem is how it uses document.querySelectorAll('.draggable-header') to select the headers. Is there a better way to write this using React ref callback API?

    mountEvents() {
        const headers = Array.prototype.slice.call(
            document.querySelectorAll('.draggable-header')
        );

        headers.forEach((header, i) => {

            header.setAttribute('draggable', true);
            //the dragged header
            header.ondragstart = e => {
                // console.log('header being dragged');
                e.stopPropagation();
                this.dragged = i;
            };

            header.ondrag = e => e.stopPropagation;

            header.ondragend = e => {
                e.stopPropagation();
                setTimeout(() => (this.dragged = null), 1000);
            };

            // the dropped header
            header.ondragover = e => {
                e.preventDefault();
            };

            // TO-DO: need to call this somehow??
            header.ondrop = e => {
                e.preventDefault();
                this.reorder.push({ a: i, b: this.dragged });
                this.setState({ trigger: Math.random() });
            };
        });
    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kieronsutton00 picture kieronsutton00  路  3Comments

danielmariz picture danielmariz  路  3Comments

mlajszczak picture mlajszczak  路  3Comments

alexanderwhatley picture alexanderwhatley  路  3Comments

panfiva picture panfiva  路  3Comments