mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Scenes: Unset _changesWorker when change tracker is terminated (#89495)
* Scenes: Unset _changesWorker when change tracker is terminated Closes #89458
This commit is contained in:
parent
e5474511d8
commit
d750af0c48
@ -2838,6 +2838,10 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
|
||||
],
|
||||
"public/app/features/dashboard-scene/saving/DashboardSceneChangeTracker.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx:5381": [
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
|
||||
|
@ -0,0 +1,23 @@
|
||||
import * as createDetectChangesWorker from 'app/features/dashboard-scene/saving/createDetectChangesWorker';
|
||||
|
||||
import { DashboardSceneChangeTracker } from './DashboardSceneChangeTracker';
|
||||
|
||||
describe('DashboardSceneChangeTracker', () => {
|
||||
it('should set _changesWorker to undefined when terminate is called', () => {
|
||||
const terminate = jest.fn();
|
||||
jest.spyOn(createDetectChangesWorker, 'createWorker').mockImplementation(
|
||||
() =>
|
||||
({
|
||||
terminate,
|
||||
}) as any
|
||||
);
|
||||
const changeTracker = new DashboardSceneChangeTracker({
|
||||
subscribeToEvent: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
|
||||
} as any);
|
||||
changeTracker.startTrackingChanges();
|
||||
|
||||
expect(changeTracker['_changesWorker']).not.toBeUndefined();
|
||||
changeTracker.terminate();
|
||||
expect(changeTracker['_changesWorker']).toBeUndefined();
|
||||
});
|
||||
});
|
@ -188,5 +188,6 @@ export class DashboardSceneChangeTracker {
|
||||
public terminate() {
|
||||
this.stopTrackingChanges();
|
||||
this._changesWorker?.terminate();
|
||||
this._changesWorker = undefined;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user