|
1 | | -import { inheritAriaAttributes } from './helpers'; |
| 1 | +import { inheritAriaAttributes, isEndSide } from './helpers'; |
| 2 | + |
| 3 | +describe('isEndSide', () => { |
| 4 | + afterEach(() => { |
| 5 | + document.dir = 'ltr'; |
| 6 | + }); |
| 7 | + |
| 8 | + it('should use document direction when no host element is provided', () => { |
| 9 | + document.dir = 'rtl'; |
| 10 | + expect(isEndSide('start')).toBe(true); |
| 11 | + expect(isEndSide('end')).toBe(false); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should use the nearest ancestor dir attribute', () => { |
| 15 | + document.dir = 'ltr'; |
| 16 | + |
| 17 | + const app = document.createElement('ion-app'); |
| 18 | + app.setAttribute('dir', 'rtl'); |
| 19 | + |
| 20 | + const menu = document.createElement('ion-menu'); |
| 21 | + app.appendChild(menu); |
| 22 | + document.body.appendChild(app); |
| 23 | + |
| 24 | + expect(isEndSide('start', menu)).toBe(true); |
| 25 | + expect(isEndSide('end', menu)).toBe(false); |
| 26 | + |
| 27 | + document.body.removeChild(app); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should fall back to document direction when no ancestor has dir', () => { |
| 31 | + document.dir = 'rtl'; |
| 32 | + |
| 33 | + const menu = document.createElement('ion-menu'); |
| 34 | + document.body.appendChild(menu); |
| 35 | + |
| 36 | + expect(isEndSide('start', menu)).toBe(true); |
| 37 | + expect(isEndSide('end', menu)).toBe(false); |
| 38 | + |
| 39 | + document.body.removeChild(menu); |
| 40 | + }); |
| 41 | +}); |
2 | 42 |
|
3 | 43 | describe('inheritAriaAttributes', () => { |
4 | 44 | it('should inherit aria attributes', () => { |
|
0 commit comments