|
| 1 | +/* eslint-disable prefer-destructuring */ |
| 2 | +import {fixture, assert, aTimeout} from '@open-wc/testing' |
| 3 | +import { AmfLoader } from './amf-loader.js'; |
| 4 | +import '../api-type-document.js'; |
| 5 | + |
| 6 | +/** @typedef {import('..').ApiTypeDocument} ApiTypeDocument */ |
| 7 | +/** @typedef {import('..').PropertyShapeDocument} PropertyShapeDocument */ |
| 8 | +/** @typedef {import('@api-components/amf-helper-mixin').AmfDocument} AmfDocument */ |
| 9 | + |
| 10 | +describe('<api-type-document>', () => { |
| 11 | + const file = 'W-12137562'; |
| 12 | + |
| 13 | + /** |
| 14 | + * @returns {Promise<ApiTypeDocument>} |
| 15 | + */ |
| 16 | + async function basicFixture() { |
| 17 | + return fixture(`<api-type-document></api-type-document>`); |
| 18 | + } |
| 19 | + |
| 20 | + [ |
| 21 | + ['Regular model', false], |
| 22 | + ['Compact model', true], |
| 23 | + ].forEach((item) => { |
| 24 | + describe(String(item[0]), () => { |
| 25 | + let element = /** @type ApiTypeDocument */ (null); |
| 26 | + beforeEach(async () => { |
| 27 | + element = await basicFixture(); |
| 28 | + }); |
| 29 | + |
| 30 | + it('renders complex element', async () => { |
| 31 | + const data = await AmfLoader.loadType('Pet', item[1], file); |
| 32 | + element.amf = data[0]; |
| 33 | + element.type = data[1]; |
| 34 | + await aTimeout(0); |
| 35 | + |
| 36 | + const shape = element.shadowRoot.querySelector('property-shape-document') |
| 37 | + assert.ok(shape); |
| 38 | + |
| 39 | + /** @type HTMLElement */ (shape.shadowRoot.querySelector('.complex-toggle')).click(); |
| 40 | + await aTimeout(0); |
| 41 | + await aTimeout(0); |
| 42 | + |
| 43 | + assert.ok(shape.shadowRoot.querySelector('api-type-document.children.complex')); |
| 44 | + }); |
| 45 | + }); |
| 46 | + }); |
| 47 | +}); |
0 commit comments