{"size": 2651, "ext": "js", "max_stars_repo_path": "force-app/main/default/lwc/recordViewFormStaticContact/__tests__/recordViewFormStaticContact.test.js", "max_stars_repo_name": "technolau/lwc-recipes", "max_stars_repo_stars_event_min_datetime": "2019-09-30T01:52:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-12T18:55:48.000Z", "max_issues_repo_path": "force-app/main/default/lwc/recordViewFormStaticContact/__tests__/recordViewFormStaticContact.test.js", "max_issues_repo_name": "technolau/lwc-recipes", "max_issues_repo_issues_event_min_datetime": "2020-09-07T03:05:29.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T11:33:59.000Z", "max_forks_repo_path": "force-app/main/default/lwc/recordViewFormStaticContact/__tests__/recordViewFormStaticContact.test.js", "max_forks_repo_name": "twelve-consulting/salesforce-lightning-web-components", "max_forks_repo_forks_event_min_datetime": "2021-11-07T05:27:38.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-08T12:12:39.000Z"}
{"max_stars_count": 4, "max_issues_count": 3, "max_forks_count": 2, "avg_line_length": 35.3466666667, "max_line_length": 91, "alphanum_fraction": 0.5914749151}
import { createElement } from 'lwc';
import RecordViewFormStaticContact from 'c/recordViewFormStaticContact';

describe('c-record-view-form-static-contact', () => {
    afterEach(() => {
        // The jsdom instance is shared across test cases in a single file so reset the DOM
        while (document.body.firstChild) {
            document.body.removeChild(document.body.firstChild);
        }
    });

    it('renders lightning-record-view-form with given input values', () => {
        const RECORD_ID_INPUT = '0031700000pJRRSAA4';
        const OBJECT_API_NAME_INPUT = 'Contact';

        // Create initial element
        const element = createElement('c-record-view-form-static-contact', {
            is: RecordViewFormStaticContact
        });
        // Set public properties
        element.recordId = RECORD_ID_INPUT;
        element.objectApiName = OBJECT_API_NAME_INPUT;
        document.body.appendChild(element);

        // Validate if correct parameters have been passed to base components
        const formEl = element.shadowRoot.querySelector(
            'lightning-record-view-form'
        );
        expect(formEl.recordId).toBe(RECORD_ID_INPUT);
        expect(formEl.objectApiName).toBe(OBJECT_API_NAME_INPUT);
    });

    it('renders given set of lightning-output-field`s in specific order', () => {
        const OUTPUT_FIELDS = [
            {
                fieldApiName: 'AccountId',
                objectApiName: 'Contact'
            },
            {
                fieldApiName: 'Name',
                objectApiName: 'Contact'
            },
            {
                fieldApiName: 'Title',
                objectApiName: 'Contact'
            },
            {
                fieldApiName: 'Phone',
                objectApiName: 'Contact'
            },
            {
                fieldApiName: 'Email',
                objectApiName: 'Contact'
            }
        ];
        const RECORD_ID_INPUT = '0031700000pJRRSAA4';
        const OBJECT_API_NAME_INPUT = 'Contact';

        // Create initial element
        const element = createElement('c-record-view-form-static-contact', {
            is: RecordViewFormStaticContact
        });
        // Set public properties
        element.recordId = RECORD_ID_INPUT;
        element.objectApiName = OBJECT_API_NAME_INPUT;
        document.body.appendChild(element);

        // Select elements for validation
        const outputFieldNames = Array.from(
            element.shadowRoot.querySelectorAll('lightning-output-field')
        ).map(outputField => outputField.fieldName);
        expect(outputFieldNames).toEqual(OUTPUT_FIELDS);
    });
});
