Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {assert} from 'chai'; |
| 6 | import {MrIssueDetails} from './mr-issue-details.js'; |
| 7 | |
| 8 | let element; |
| 9 | |
| 10 | describe('mr-issue-details', () => { |
| 11 | beforeEach(() => { |
| 12 | element = document.createElement('mr-issue-details'); |
| 13 | document.body.appendChild(element); |
| 14 | }); |
| 15 | |
| 16 | afterEach(() => { |
| 17 | document.body.removeChild(element); |
| 18 | }); |
| 19 | |
| 20 | it('initializes', () => { |
| 21 | assert.instanceOf(element, MrIssueDetails); |
| 22 | }); |
| 23 | |
| 24 | it('mr-edit-issue is displayed if user has addissuecomment', async () => { |
| 25 | element.issuePermissions = ['addissuecomment']; |
| 26 | |
| 27 | await element.updateComplete; |
| 28 | |
| 29 | assert.isNotNull(element.querySelector('mr-edit-issue')); |
| 30 | }); |
| 31 | |
| 32 | it('mr-edit-issue is hidden if user has no addissuecomment', async () => { |
| 33 | element.issuePermissions = []; |
| 34 | |
| 35 | await element.updateComplete; |
| 36 | |
| 37 | assert.isNull(element.querySelector('mr-edit-issue')); |
| 38 | }); |
| 39 | }); |