|
| 1 | +/* |
| 2 | + * Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | + |
| 18 | +import SVGTask from '@/components/cylc/SVGTask.vue' |
| 19 | +import { mount } from '@vue/test-utils' |
| 20 | + |
| 21 | +describe('modifier', () => { |
| 22 | + it.each([ |
| 23 | + // isHeld takes priority over everything else: |
| 24 | + [['isHeld'], 'held'], |
| 25 | + [['isQueued', 'isHeld'], 'held'], |
| 26 | + [['isHeld', 'isRunahead'], 'held'], |
| 27 | + [['isHeld', 'isRetry'], 'held'], |
| 28 | + [['isHeld', 'isWallclock'], 'held'], |
| 29 | + [['isHeld', 'isQueued'], 'held'], |
| 30 | + [['isHeld', 'isXtriggered', 'isRunahead', 'isRetry', 'isQueued', 'isWallclock'], 'held'], |
| 31 | + // isXtriggered is bottom of the list: |
| 32 | + [['isXtriggered'], 'xtriggered'], |
| 33 | + [['isRunahead', 'isXtriggered'], 'runahead'], |
| 34 | + [['isRetry', 'isXtriggered'], 'retry'], |
| 35 | + [['isWallclock', 'isXtriggered'], 'wallclock'], |
| 36 | + [['isHeld', 'isWallclock', 'isXtriggered'], 'held'], |
| 37 | + // Some cases in the middle of the list: |
| 38 | + [['isQueued', 'isRunahead', 'isXtriggered'], 'queued'], |
| 39 | + [['isRunahead', 'isRetry', 'isWallclock'], 'runahead'], |
| 40 | + ])('returns the correct modifier for %o', (switchedOn, expected) => { |
| 41 | + const wrapper = mount(SVGTask, { |
| 42 | + props: { |
| 43 | + task: Object.fromEntries( |
| 44 | + switchedOn.map((modifier) => [modifier, true]) |
| 45 | + ), |
| 46 | + } |
| 47 | + }) |
| 48 | + expect(wrapper.vm.modifier).toBe(expected) |
| 49 | + expect(wrapper.get('.c8-task').classes()).toContain(expected) |
| 50 | + }) |
| 51 | +}) |
0 commit comments