|
| 1 | +import { fixture, assert, html } from '@open-wc/testing'; |
| 2 | +import { AmfLoader } from './amf-loader.js'; |
| 3 | +import '../api-example-generator.js'; |
| 4 | + |
| 5 | +describe('W-17413312', () => { |
| 6 | + async function basicFixture(amf) { |
| 7 | + return (await fixture(html`<api-example-generator |
| 8 | + .amf="${amf}"></api-example-generator>`)); |
| 9 | + } |
| 10 | + |
| 11 | + const apiFile = 'W-17413312'; |
| 12 | + |
| 13 | + [ |
| 14 | + ['json+ld data model', false], |
| 15 | + ['Compact data model', true] |
| 16 | + ].forEach(([label, compact]) => { |
| 17 | + describe(label, () => { |
| 18 | + let element; |
| 19 | + let amf; |
| 20 | + |
| 21 | + before(async () => { |
| 22 | + amf = await AmfLoader.load(compact, apiFile); |
| 23 | + }); |
| 24 | + |
| 25 | + beforeEach(async () => { |
| 26 | + element = await basicFixture(amf); |
| 27 | + }); |
| 28 | + |
| 29 | + it('renders examples right', () => { |
| 30 | + const payloads = AmfLoader.lookupReturnsPayload(amf, '/sources', 'get', 200); |
| 31 | + const result = element.generatePayloadsExamples(payloads, 'application/json'); |
| 32 | + assert.typeOf(result, 'array'); |
| 33 | + const item = result[0]; |
| 34 | + assert.equal(item.value, `{ |
| 35 | + "data": [ |
| 36 | + { |
| 37 | + "id": "64f1f0d46ad16b6acdaa3e0e", |
| 38 | + "name": "Main Station Track 5a", |
| 39 | + "type": "Camera", |
| 40 | + "class": "Common", |
| 41 | + "audio": { |
| 42 | + "isEnabled": true |
| 43 | + }, |
| 44 | + "externalReference": "b8755c8d-ef9d-4a7e-a8a2-7b5abace1af7", |
| 45 | + "streams": [ |
| 46 | + { |
| 47 | + "id": "64f1eff26ad16b6acdaa3e08", |
| 48 | + "url": "rtsp://ipcam573.example.com:554/live/ch0", |
| 49 | + "decoderOptions": { |
| 50 | + "protocols": 2, |
| 51 | + "tcp-timeout": 10000000 |
| 52 | + } |
| 53 | + } |
| 54 | + ], |
| 55 | + "authentication": {} |
| 56 | + } |
| 57 | + ], |
| 58 | + "meta": {} |
| 59 | +}`); |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | +}); |
0 commit comments