blob: 5cc4e6db802e1f9f2da36b44fdce6a1802f71d1a [file] [log] [blame]
/**
* @license
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '../../../test/common-test-setup-karma';
import {fixture} from '@open-wc/testing-helpers';
import {html} from 'lit';
import './gr-change-list-column-requirements-summary';
import {GrChangeListColumnRequirementsSummary} from './gr-change-list-column-requirements-summary';
import {
createApproval,
createDetailedLabelInfo,
createParsedChange,
createSubmitRequirementExpressionInfo,
createSubmitRequirementResultInfo,
createNonApplicableSubmitRequirementResultInfo,
} from '../../../test/test-data-generators';
import {
SubmitRequirementResultInfo,
SubmitRequirementStatus,
} from '../../../api/rest-api';
import {ParsedChangeInfo} from '../../../types/types';
suite('gr-change-list-column-requirements-summary tests', () => {
let element: GrChangeListColumnRequirementsSummary;
let change: ParsedChangeInfo;
setup(() => {
const submitRequirement: SubmitRequirementResultInfo = {
...createSubmitRequirementResultInfo(),
status: SubmitRequirementStatus.UNSATISFIED,
description: 'Test Description',
submittability_expression_result: createSubmitRequirementExpressionInfo(),
};
change = {
...createParsedChange(),
submit_requirements: [
submitRequirement,
createNonApplicableSubmitRequirementResultInfo(),
],
labels: {
Verified: {
...createDetailedLabelInfo(),
all: [
{
...createApproval(),
value: 2,
},
],
},
},
};
});
test('renders', async () => {
element = await fixture<GrChangeListColumnRequirementsSummary>(
html`<gr-change-list-column-requirements-summary .change=${change}>
</gr-change-list-column-requirements-summary>`
);
expect(element).shadowDom.to.equal(/* HTML */ ` <span
class="block"
role="button"
tabindex="0"
>
<gr-submit-requirement-dashboard-hovercard>
</gr-submit-requirement-dashboard-hovercard>
<iron-icon class="block" icon="gr-icons:block" role="img"></iron-icon>
<span>
<span class="unsatisfied">1</span>
<span class="total">(of 1)</span>
</span>
</span>`);
});
test('renders comment count', async () => {
change = {
...change,
unresolved_comment_count: 5,
};
element = await fixture<GrChangeListColumnRequirementsSummary>(
html`<gr-change-list-column-requirements-summary .change=${change}>
</gr-change-list-column-requirements-summary>`
);
expect(element).shadowDom.to.equal(/* HTML */ ` <span
class="block"
role="button"
tabindex="0"
>
<gr-submit-requirement-dashboard-hovercard>
</gr-submit-requirement-dashboard-hovercard>
<iron-icon class="block" icon="gr-icons:block" role="img"></iron-icon>
<span>
<span class="unsatisfied">1</span>
<span class="total">(of 1)</span>
</span>
</span>
<iron-icon
class="commentIcon"
icon="gr-icons:comment"
title="5 unresolved comments"
></iron-icon>`);
});
});