Skip to content

Conversation

@megawac
Copy link
Contributor

@megawac megawac commented Nov 15, 2024

I wasn't sure if this requires unit tests, there don't appear to be similar types of unit tests in the VectorSource test suite

Fixes #16367

@github-actions
Copy link

📦 Preview the website for this branch here: https://deploy-preview-16370--ol-site.netlify.app/.

Copy link
Contributor

@jahow jahow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution! These were indeed missing.

In order to merge this we need additional unit tests, you can find similar ones here:

describe('#dispose', () => {
let deleteBufferSpy;
beforeEach(async () => {
// first call prepareFrame to load initial data and register listeners
renderer.prepareFrame(frameState);
await new Promise((resolve) => setTimeout(resolve, 150));
sinonSpy(vectorSource, 'removeEventListener');
deleteBufferSpy = sinonSpy(renderer.helper, 'deleteBuffer');
renderer.dispose();
});
it('unlistens to source events', () => {
expect(
vectorSource.removeEventListener.calledWith(VectorEventType.ADDFEATURE),
).to.be(true);
expect(
vectorSource.removeEventListener.calledWith(
VectorEventType.CHANGEFEATURE,
),
).to.be(true);
expect(
vectorSource.removeEventListener.calledWith(
VectorEventType.REMOVEFEATURE,
),
).to.be(true);
expect(
vectorSource.removeEventListener.calledWith(VectorEventType.CLEAR),
).to.be(true);
});
it('deletes webgl buffers', () => {
expect(deleteBufferSpy.callCount).to.be(12); // 2 buffers * 3 types of geometry * 2 different styles
});
});

Let me know if you can handle this; otherwise I might take a look. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VectorSource does not cleanup subscriptions to bound Collection

2 participants