{"size": 3056, "ext": "js", "max_stars_repo_path": "web/tests/pager_duty_view_spec.js", "max_stars_repo_name": "aquanauts/terrain", "max_stars_repo_stars_event_min_datetime": "2020-06-11T21:26:53.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T04:11:36.000Z", "max_issues_repo_path": "web/tests/pager_duty_view_spec.js", "max_issues_repo_name": "aquanauts/terrain", "max_issues_repo_issues_event_min_datetime": "2020-06-16T19:26:12.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-20T21:17:46.000Z", "max_forks_repo_path": "web/tests/pager_duty_view_spec.js", "max_forks_repo_name": "aquanauts/terrain", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 32, "max_forks_count": null, "avg_line_length": 43.6571428571, "max_line_length": 179, "alphanum_fraction": 0.6197643979}
import pagerDutyView from '/js/views/pagerDutyView.js';

describe('Pager Duty View', () => {
    
    let getDeferred, postDeferred, view;   

    beforeEach(() => {
        getDeferred = $.Deferred();
        spyOn($, 'get').and.returnValue(getDeferred);

        postDeferred =  $.Deferred(); //TODO make assertions about the arguments to post
        spyOn($, 'post').and.returnValue(postDeferred);
        view = pagerDutyView(1);
    });

    it('Describes purpose of view', async () => {
        expect(view.find('h1').text()).toEqual("Pager Duty");
        expect(view.find('p').text()).toEqual("If you would like to receive PagerDuty alerts for significant errors on your applications, you can manage your routing keys here.");
    });


    it('Contains a form for adding new routing key information with 3 fields and a submit button', async () => {
        const firstSubHeading = view.find('h3')[0];
        expect(firstSubHeading.textContent).toEqual("Add Routing Key");
        const inputForm = view.find('form');
        const inputBoxes = inputForm.find('input');
        expect(inputBoxes.length).toEqual(3);
        expect(inputBoxes[1].placeholder).toEqual("e.g. http://terrain.aq.tc/");
        expect(inputForm.find("button").text()).toEqual("Submit");
    });
    
    /*it('Submits information, checking for incomplete forms or repeated key name', async () => {
        //spyOn($, 'post')
        getDeferred.resolve('{} \n');
        const firstHeading = view.find('tr:first th:first');
        const lastHeading = view.find('tr:first th:last');
        expect(firstHeading.text()).toEqual("No.");
        expect(lastHeading.text()).toEqual("URL");
        expect
    });

    /*it('Renders the current routing information in a table with checkboxes and an option to delete', async () => {
        //generatePagerDutyKeyTable(view.find('table')[1]);
        let currentInfo = '{"name":"Name", "host":"gracious, "key":"12345"}'
        currentKeyInfo.resolve(currentInfo);
        const firstHostName = view.find('tbody')[1].find('tr:nth-child(1) td:nth-child(3)');
        const firstTableCell = view.find('tbody')[1].find('tr:nth-child(1) td:nth-child(1)');
        expect(firstHostName).toEqual('gracious');
        const firstCheckBox =  firstTableCell.find('input').attr('type').toEqual('checkbox');
        expect(view.find('button')[1].textContent).toEqual("Delete Selected Keys");
    });
    
    it('Deletes selected keys', async () => {
        errorInfoDeferred.resolve('{} \n');
        const firstHeading = view.find('tr:first th:first');
        const lastHeading = view.find('tr:first th:last');
        expect($, 'ajax').toHaveBeenCalledWith();
    });
    
    it('Shows updated table after submit or delete actions', async () => {
        errorInfoDeferred.resolve('{} \n');
        const firstHeading = view.find('tr:first th:first');
        const lastHeading = view.find('tr:first th:last');
        expect(firstHeading.text()).toEqual("No.");
        expect(lastHeading.text()).toEqual("URL");
    });
*/

});
