Skip to content

Commit d8fe68a

Browse files
authored
Merge pull request #636 from mulesoft/feat/add-custom-base-uri-slot
chore: add custom base uri slot to api-request-panel
2 parents a3d74a9 + eb276c9 commit d8fe68a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/ApiConsole.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
264264
.allowHideOptional="${allowHideOptional}"
265265
.baseUri="${baseUri}"
266266
.noDocs="${noDocs}"
267-
.eventsTarget="${eventsTarget}"></api-request-panel>`;
267+
.eventsTarget="${eventsTarget}">
268+
<slot name="custom-base-uri" slot="custom-base-uri"></slot>
269+
</api-request-panel>`;
268270
}
269271

270272
_apiDocumentationTemplate() {

test/api-console.basic.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ describe('<api-console>', function() {
2929
return (await fixture(`<api-console allowExtensionBanner page="request"></api-console>`));
3030
}
3131

32+
async function customBaseUriSlotFixture() {
33+
return (await fixture(`<api-console page="request"><anypoint-item slot="custom-base-uri"
34+
value="http://customServer.com">http://customServer.com</anypoint-item></api-console>`));
35+
}
36+
3237
describe('RAML aware', () => {
3338
it('Adds raml-aware to the DOM if aware is set', async () => {
3439
const element = await awareFixture();
@@ -430,4 +435,33 @@ describe('<api-console>', function() {
430435
assert.isFalse(banner.hasAttribute('active'), 'banner is not active');
431436
});
432437
});
438+
439+
describe('Custom baseUri slot', () => {
440+
describe('with requestFixture', () => {
441+
let element;
442+
beforeEach(async () => {
443+
element = await requestFixture();
444+
});
445+
446+
it('should render empty extra servers slot', () => {
447+
assert.exists(element.shadowRoot.querySelector('slot[name="custom-base-uri"]'));
448+
assert.lengthOf(element.shadowRoot.querySelector('slot[name="custom-base-uri"]').assignedNodes(), 0)
449+
});
450+
});
451+
452+
describe('with customBaseUriSlot fixture', () => {
453+
let element;
454+
beforeEach(async () => {
455+
element = await customBaseUriSlotFixture();
456+
});
457+
458+
it('should render extra servers slot', () => {
459+
assert.exists(element.shadowRoot.querySelector('slot[name="custom-base-uri"]'));
460+
});
461+
462+
it('should have assigned node to slot', () => {
463+
assert.lengthOf(element.shadowRoot.querySelector('slot[name="custom-base-uri"]').assignedNodes(), 1);
464+
});
465+
});
466+
});
433467
});

0 commit comments

Comments
 (0)