Paladox | 37032f8 | 2017-07-01 13:40:01 +0100 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | Copyright (C) 2017 The Android Open Source Project |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | --> |
| 17 | |
| 18 | <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| 19 | <title>gr-confirm-delete-item-dialog</title> |
| 20 | |
| 21 | <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> |
| 22 | <script src="../../../bower_components/web-component-tester/browser.js"></script> |
| 23 | <link rel="import" href="../../../test/common-test-setup.html"/> |
| 24 | <link rel="import" href="gr-confirm-delete-item-dialog.html"> |
| 25 | |
| 26 | <script>void(0);</script> |
| 27 | |
| 28 | <test-fixture id="basic"> |
| 29 | <template> |
| 30 | <gr-confirm-delete-item-dialog></gr-confirm-delete-item-dialog> |
| 31 | </template> |
| 32 | </test-fixture> |
| 33 | |
| 34 | <script> |
| 35 | suite('gr-confirm-delete-item-dialog tests', () => { |
| 36 | let element; |
| 37 | let sandbox; |
| 38 | |
| 39 | setup(() => { |
| 40 | sandbox = sinon.sandbox.create(); |
| 41 | element = fixture('basic'); |
| 42 | }); |
| 43 | |
| 44 | teardown(() => { |
| 45 | sandbox.restore(); |
| 46 | }); |
| 47 | |
| 48 | test('_handleConfirmTap', () => { |
| 49 | const confirmHandler = sandbox.stub(); |
| 50 | element.addEventListener('confirm', confirmHandler); |
| 51 | sandbox.stub(element, '_handleConfirmTap'); |
| 52 | element.$$('gr-confirm-dialog').fire('confirm'); |
| 53 | assert.isTrue(confirmHandler.called); |
| 54 | assert.isTrue(element._handleConfirmTap.called); |
| 55 | }); |
| 56 | |
| 57 | test('_handleCancelTap', () => { |
| 58 | const cancelHandler = sandbox.stub(); |
| 59 | element.addEventListener('cancel', cancelHandler); |
| 60 | sandbox.stub(element, '_handleCancelTap'); |
| 61 | element.$$('gr-confirm-dialog').fire('cancel'); |
| 62 | assert.isTrue(cancelHandler.called); |
| 63 | assert.isTrue(element._handleCancelTap.called); |
| 64 | }); |
| 65 | |
| 66 | test('_computeItemName function for branches', () => { |
| 67 | assert.deepEqual(element._computeItemName('branches'), 'Branch'); |
| 68 | assert.notEqual(element._computeItemName('branches'), 'Tag'); |
| 69 | }); |
| 70 | |
| 71 | test('_computeItemName function for tags', () => { |
| 72 | assert.deepEqual(element._computeItemName('tags'), 'Tag'); |
| 73 | assert.notEqual(element._computeItemName('tags'), 'Branch'); |
| 74 | }); |
| 75 | }); |
| 76 | </script> |