Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix commented out Tests for loading Search Results
Fix the commented out tests for loading SearchBox search results and rendering them with HTML, due to an asynchronous problem when running tests, where occasionally the answer will change depending on whether the results come back in time; meaning one of two answers will be true and the other false, depending on when it is called or if it is called multiple times; e.g. ```javascript it('_getResults (after AJAX request with no params)', function (done) { const _subject = new describedClass(); _subject.reRenderCallback = function expectedResults(component, _) { const results = component._getResults(); expect([ jasmine.any(NullSearchResult), jasmine.any(NullComponent) ]).toContain(results); }; _subject._searchFromServer('', '', '', function(_error, searchbox) { var results = searchbox._getResults(); expect(results).toEqual(jasmine.any(NullSearchResult)); done(); }); }); ``` The SearchBox will be rendered normally on first load containing a `NullComponent` as a placeholder component until results are loaded, in this case it returns no results for an empty search and then renders a `NullSearchResult` component. However, the test will fail unless it is true for at least one of them when the other is not present; i.e. - Is true when it renders `NullComponent` and not `NullSearchResult`, and - Is true when it renders `NulLSearchResult` and not `NullComponent`, but - Is not true when it only renders one of them (since one or the other is rendered at some point in the future) == Notes: - Some tests have remained disabled since the `'_searchFromServer returns expected flights data'` test only returns expected results data if `_searchFromServer()` is not called multiple time prior to it (meaning it may fail on other computers <sigh>) == References: - [Pass callback to wrapper.setState · Issue #509 · airbnb/enzyme] (enzymejs/enzyme#509) - [node.js - How do I change the timeout on a jasmine-node async spec - Stack Overflow] (https://stackoverflow.com/questions/9867601/how-do-i-change-the-timeout-on-a-jasmine-node-async-spec)
- Loading branch information