From b0eee4fcd29dca54823476b4b0844497328f6ab3 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 19 May 2021 11:31:40 +0200 Subject: Add findActionButton helped globally for tests Signed-off-by: Vincent Petry --- src/test-helpers.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test-helpers.js (limited to 'src/test-helpers.js') diff --git a/src/test-helpers.js b/src/test-helpers.js new file mode 100644 index 000000000..dbfafd185 --- /dev/null +++ b/src/test-helpers.js @@ -0,0 +1,39 @@ +/* + * @copyright Copyright (c) 2019 Julius Härtl + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' + +// helpers +const findActionButton = function(wrapper, text) { + const actionButtons = wrapper.findAllComponents(ActionButton) + const items = actionButtons.filter(actionButton => { + return actionButton.text() === text + }) + if (!items.exists()) { + return items + } + return items.at(0) +} + +export { + findActionButton, +} -- cgit v1.2.3