'use strict';

/* Written by Carl, test for search.js (used for objs such as expts and
biosources). Test data captured from Nov. 2016 metadata.*/

jest.autoMockOff();

// Fixes https://github.com/facebook/jest/issues/78
jest.dontMock('react');
jest.dontMock('underscore');


describe('Testing search.js', function() {
    var React, Search, testSearch, TestUtils, context, schemas, _;

    beforeEach(function() {
        React = require('react');
        TestUtils = require('react-dom/lib/ReactTestUtils');
        _ = require('underscore');
        Search = require('../search').Search;
        context = require('../testdata/expt_search');

        testSearch = TestUtils.renderIntoDocument(
            <Search context={context} href="/search/?type=ExperimentHiC" />
        );

    });

    it('has the correct number of facets and experiment accessions listed', function() {
        var facets = TestUtils.scryRenderedDOMComponentsWithClass(testSearch, 'facet');
        var results = TestUtils.scryRenderedDOMComponentsWithClass(testSearch, 'result-table-result');
        expect(facets.length).toEqual(8);
        expect(results.length).toEqual(5);
    });

    it('has a good title', function() {
        var titleLine = TestUtils.findRenderedDOMComponentWithTag(testSearch, 'h1');
        expect(titleLine.textContent).toEqual('ExperimentHiC Search');
    });

    it('facets properly (digestion_enzyme=hindIII)', function() {
        context = require('../testdata/expt_search_hindIII');
        testSearch = TestUtils.renderIntoDocument(
            <Search context={context} href='/search/?type=ExperimentHiC&digestion_enzyme.name=HindIII' />
        );
        var results = TestUtils.scryRenderedDOMComponentsWithClass(testSearch, 'result-table-result');
        var selectedFacets = TestUtils.scryRenderedDOMComponentsWithClass(testSearch, 'selected');
        expect(results.length).toEqual(2);
        expect(selectedFacets.length).toEqual(1);
    });
});

@@ -1102,15 +1102,23 @@
 ).to
-Equal(8
+BeGreaterThan(7
 );%0A 
@@ -1960,17 +1960,17 @@
 toEqual(
-1
+2
 );%0A    %7D

Test fix