<commit_before>
'use strict';

jest.autoMockOff();

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


describe('Experiment Page', function() {
    var React, TestUtils, Experiment, FetchContext, context, _;

    beforeEach(function() {
        React = require('react');
        TestUtils = require('react/lib/ReactTestUtils');
        _ = require('underscore');

        Experiment = require('../experiment').Experiment;
        context = require('../testdata/experiment');

        FetchContext = {
            fetch: function(url, options) {
                return Promise.resolve({json: () => ({'@graph': []})});
            }
        };
    });

    describe('Minimal Experiment', function() {
        var experiment, summary, defTerms, defDescs;

        beforeEach(function() {
            context.references = [require('../testdata/publication/PMID16395128'), require('../testdata/publication/PMID23000965')];
            experiment = React.withContext(FetchContext, function() {
                return TestUtils.renderIntoDocument(
                    <Experiment context={context} />
                );
            });

            summary = TestUtils.scryRenderedDOMComponentsWithClass(experiment, 'data-display');
            defTerms = summary[0].getDOMNode().getElementsByTagName('dt');
            defDescs = summary[0].getDOMNode().getElementsByTagName('dd');
        });

        it('has correct summary panel and key-value elements counts within it', function() {
            expect(summary.length).toEqual(1);
            expect(defTerms.length).toEqual(9);
            expect(defDescs.length).toEqual(9);
        });

        it('has proper biosample summary for no-biosample case (code adds space always)', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="biosample-summary"]');
            var desc = item.getElementsByTagName('dd')[0];
            expect(desc.textContent).toEqual('K562 ');
        });

        it('has proper links in dbxrefs key-value', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="external-resources"]');
            var desc = item.getElementsByTagName('dd')[0];
            var dbxrefs = desc.getElementsByTagName('a');
            expect(dbxrefs.length).toEqual(2);
            expect(dbxrefs[0].getAttribute('href')).toEqual('http://genome.ucsc.edu/cgi-bin/hgTracks?tsCurTab=advancedTab&tsGroup=Any&tsType=Any&hgt_mdbVar1=dccAccession&hgt_tSearch=search&hgt_tsDelRow=&hgt_tsAddRow=&hgt_tsPage=&tsSimple=&tsName=&tsDescr=&db=hg19&hgt_mdbVal1=wgEncodeEH003317');
            expect(dbxrefs[1].getAttribute('href')).toEqual('http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM1010811');
        });

        it('has proper release date', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="date-released"]');
            var desc = item.getElementsByTagName('dd')[0];
            expect(desc.textContent).toEqual('2011-10-29');
        });

        it('has two experiment status elements in header', function() {
            var statusList = TestUtils.findRenderedDOMComponentWithClass(experiment, 'status-list').getDOMNode();
            expect(statusList.hasChildNodes()).toBeTruthy();
            expect(statusList.childNodes.length).toEqual(2);
        });<commit_msg>Fix changed Jest test<commit_after>
'use strict';

jest.autoMockOff();

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


describe('Experiment Page', function() {
    var React, TestUtils, Experiment, FetchContext, context, _;

    beforeEach(function() {
        React = require('react');
        TestUtils = require('react/lib/ReactTestUtils');
        _ = require('underscore');

        Experiment = require('../experiment').Experiment;
        context = require('../testdata/experiment');

        FetchContext = {
            fetch: function(url, options) {
                return Promise.resolve({json: () => ({'@graph': []})});
            }
        };
    });

    describe('Minimal Experiment', function() {
        var experiment, summary, defTerms, defDescs;

        beforeEach(function() {
            context.references = [require('../testdata/publication/PMID16395128'), require('../testdata/publication/PMID23000965')];
            experiment = React.withContext(FetchContext, function() {
                return TestUtils.renderIntoDocument(
                    <Experiment context={context} />
                );
            });

            summary = TestUtils.scryRenderedDOMComponentsWithClass(experiment, 'data-display');
            defTerms = summary[0].getDOMNode().getElementsByTagName('dt');
            defDescs = summary[0].getDOMNode().getElementsByTagName('dd');
        });

        it('has correct summary panel and key-value elements counts within it', function() {
            expect(summary.length).toEqual(1);
            expect(defTerms.length).toEqual(9);
            expect(defDescs.length).toEqual(9);
        });

        it('has proper biosample summary for no-biosample case (code adds space always)', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="biosample-summary"]');
            var desc = item.getElementsByTagName('dd')[0];
            expect(desc.textContent).toEqual('K562 ');
        });

        it('has proper links in dbxrefs key-value', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="external-resources"]');
            var desc = item.getElementsByTagName('dd')[0];
            var dbxrefs = desc.getElementsByTagName('a');
            expect(dbxrefs.length).toEqual(2);
            expect(dbxrefs[0].getAttribute('href')).toEqual('http://genome.ucsc.edu/cgi-bin/hgTracks?tsCurTab=advancedTab&tsGroup=Any&tsType=Any&hgt_mdbVar1=dccAccession&hgt_tSearch=search&hgt_tsDelRow=&hgt_tsAddRow=&hgt_tsPage=&tsSimple=&tsName=&tsDescr=&db=hg19&hgt_mdbVal1=wgEncodeEH003317');
            expect(dbxrefs[1].getAttribute('href')).toEqual('http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM1010811');
        });

        it('has proper release date', function() {
            var item = summary[0].getDOMNode().querySelector('[data-test="date-released"]');
            var desc = item.getElementsByTagName('dd')[0];
            expect(desc.textContent).toEqual('2011-10-29');
        });

        it('has one experiment status element in header', function() {
            var statusList = TestUtils.findRenderedDOMComponentWithClass(experiment, 'status-list').getDOMNode();
            expect(statusList.hasChildNodes()).toBeTruthy();
            expect(statusList.childNodes.length).toEqual(1);
        });
{'fraction_non_alphanumeric': 0.152689756816507, 'fraction_numerical': 0.01798084008843036, 'mean_word_length': 2.922543352601156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7485068', 'n_tokens_mistral': 2055, 'n_tokens_neox': 1938, 'n_words': 279}