Skip to content

Commit

Permalink
render only once (#90601)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Feb 11, 2021
1 parent 9da625b commit 40570a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('embeddable', () => {
mountpoint.remove();
});

it('should render expression with expression renderer', async () => {
it('should render expression once with expression renderer', async () => {
const embeddable = new Embeddable(
{
timefilter: dataPluginMock.createSetupContract().query.timefilter.timefilter,
Expand All @@ -123,11 +123,18 @@ describe('embeddable', () => {
],
}),
},
{} as LensEmbeddableInput
{
timeRange: {
from: 'now-15m',
to: 'now',
},
} as LensEmbeddableInput
);
await embeddable.initializeSavedVis({} as LensEmbeddableInput);
embeddable.render(mountpoint);

// wait one tick to give embeddable time to initialize
await new Promise((resolve) => setTimeout(resolve, 0));

expect(expressionRenderer).toHaveBeenCalledTimes(1);
expect(expressionRenderer.mock.calls[0][0]!.expression).toEqual(`my
| expression`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ export class Embeddable
this.expression = expression ? toExpression(expression) : null;
await this.initializeOutput();
this.isInitialized = true;
if (this.domNode) {
this.render(this.domNode);
}
}

onContainerStateChanged(containerState: LensEmbeddableInput) {
Expand Down

0 comments on commit 40570a6

Please sign in to comment.