|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 OneLiteFeather |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { describe, it, expect } from 'vitest' |
| 18 | +import { h } from 'vue' |
| 19 | +import { mount } from '@vue/test-utils' |
| 20 | +import MdSaveBar from './MdSaveBar.vue' |
| 21 | + |
| 22 | +describe('MdSaveBar', () => { |
| 23 | + it('sticks to the bottom of its scroll container', () => { |
| 24 | + const wrapper = mount(MdSaveBar) |
| 25 | + |
| 26 | + expect(wrapper.classes(), 'the bar must be sticky').toContain('sticky') |
| 27 | + expect(wrapper.classes(), 'the bar must sit at the bottom edge').toContain('bottom-0') |
| 28 | + }) |
| 29 | + |
| 30 | + it('keeps the bottom clearance of the bottom bar and the safe area as a class', () => { |
| 31 | + const wrapper = mount(MdSaveBar) |
| 32 | + |
| 33 | + expect( |
| 34 | + wrapper.classes(), |
| 35 | + 'below the medium window class the bar must clear the bottom bar and the safe area' |
| 36 | + ).toContain('max-medium:bottom-[calc(var(--app-bottom-bar-height,0px)+env(safe-area-inset-bottom,0px))]') |
| 37 | + }) |
| 38 | + |
| 39 | + it('carries no inline style for the clearance', () => { |
| 40 | + const wrapper = mount(MdSaveBar) |
| 41 | + |
| 42 | + expect(wrapper.attributes('style'), 'the clearance must be a class, not a style offset').toBeUndefined() |
| 43 | + }) |
| 44 | + |
| 45 | + it('renders the default slot as the content of the bar', () => { |
| 46 | + const wrapper = mount(MdSaveBar, { |
| 47 | + slots: { default: () => h('button', { 'data-test': 'save' }, 'Save') } |
| 48 | + }) |
| 49 | + |
| 50 | + expect(wrapper.find('[data-test="save"]').exists(), 'the slot content must sit inside the bar').toBe(true) |
| 51 | + }) |
| 52 | + |
| 53 | + it('carries the md-save-bar anchor on its root', () => { |
| 54 | + const wrapper = mount(MdSaveBar) |
| 55 | + |
| 56 | + expect(wrapper.attributes('data-ingot-component')).toBe('md-save-bar') |
| 57 | + }) |
| 58 | + |
| 59 | + it('passes a caller class through to the bar', () => { |
| 60 | + const wrapper = mount(MdSaveBar, { attrs: { class: 'mt-6' } }) |
| 61 | + |
| 62 | + expect(wrapper.classes(), 'a caller class must land on the root').toContain('mt-6') |
| 63 | + }) |
| 64 | +}) |
0 commit comments