Commit 9e50721d authored by Illya Klymov's avatar Illya Klymov Committed by Paul Slaughter

Remove obsolete mutation observer stubs

parent 45ed2a3b
import { __ } from '~/locale'; import { __ } from '~/locale';
class RecentSearchesServiceError { class RecentSearchesServiceError extends Error {
constructor(message) { constructor(message) {
super(message || __('Recent Searches Service is unavailable'));
this.name = 'RecentSearchesServiceError'; this.name = 'RecentSearchesServiceError';
this.message = message || __('Recent Searches Service is unavailable');
} }
} }
// Can't use `extends` for builtin prototypes and get true inheritance yet
RecentSearchesServiceError.prototype = Error.prototype;
export default RecentSearchesServiceError; export default RecentSearchesServiceError;
...@@ -50,6 +50,15 @@ describe('EE Approvals MRRules', () => { ...@@ -50,6 +50,15 @@ describe('EE Approvals MRRules', () => {
return onTargetBranchMutationHandler(); return onTargetBranchMutationHandler();
}; };
let OriginalMutationObserver;
beforeAll(() => {
OriginalMutationObserver = global.MutationObserver;
});
afterAll(() => {
global.MutationObserver = OriginalMutationObserver;
});
beforeEach(() => { beforeEach(() => {
store = createStoreOptions(MREditModule()); store = createStoreOptions(MREditModule());
store.modules.approvals.state = { store.modules.approvals.state = {
...@@ -69,10 +78,13 @@ describe('EE Approvals MRRules', () => { ...@@ -69,10 +78,13 @@ describe('EE Approvals MRRules', () => {
describe('when editing a MR', () => { describe('when editing a MR', () => {
const initialTargetBranch = 'master'; const initialTargetBranch = 'master';
let targetBranchInputElement; let targetBranchInputElement;
let MutationObserverSpy; let MutationObserverMock;
beforeEach(() => { beforeEach(() => {
MutationObserverSpy = jest.spyOn(global, 'MutationObserver'); MutationObserverMock = jest
.fn()
.mockImplementation(args => new OriginalMutationObserver(args));
global.MutationObserver = MutationObserverMock;
targetBranchInputElement = document.createElement('input'); targetBranchInputElement = document.createElement('input');
targetBranchInputElement.id = 'merge_request_target_branch'; targetBranchInputElement.id = 'merge_request_target_branch';
...@@ -91,7 +103,7 @@ describe('EE Approvals MRRules', () => { ...@@ -91,7 +103,7 @@ describe('EE Approvals MRRules', () => {
afterEach(() => { afterEach(() => {
targetBranchInputElement.parentNode.removeChild(targetBranchInputElement); targetBranchInputElement.parentNode.removeChild(targetBranchInputElement);
MutationObserverSpy.mockClear(); MutationObserverMock.mockClear();
}); });
it('sets the target branch data to be the same value as the target branch dropdown', () => { it('sets the target branch data to be the same value as the target branch dropdown', () => {
...@@ -103,20 +115,20 @@ describe('EE Approvals MRRules', () => { ...@@ -103,20 +115,20 @@ describe('EE Approvals MRRules', () => {
it('updates the target branch data when the target branch dropdown is changed', () => { it('updates the target branch data when the target branch dropdown is changed', () => {
factory(); factory();
const newValue = setTargetBranchInputValue(); const newValue = setTargetBranchInputValue();
callTargetBranchHandler(MutationObserverSpy); callTargetBranchHandler(MutationObserverMock);
expect(wrapper.vm.targetBranch).toBe(newValue); expect(wrapper.vm.targetBranch).toBe(newValue);
}); });
it('re-fetches rules when target branch has changed', () => { it('re-fetches rules when target branch has changed', () => {
factory(); factory();
setTargetBranchInputValue(); setTargetBranchInputValue();
callTargetBranchHandler(MutationObserverSpy); callTargetBranchHandler(MutationObserverMock);
expect(store.modules.approvals.actions.fetchRules).toHaveBeenCalled(); expect(store.modules.approvals.actions.fetchRules).toHaveBeenCalled();
}); });
it('disconnects MutationObserver when component gets destroyed', () => { it('disconnects MutationObserver when component gets destroyed', () => {
const mockDisconnect = jest.fn(); const mockDisconnect = jest.fn();
MutationObserverSpy.mockImplementation(() => ({ MutationObserverMock.mockImplementation(() => ({
disconnect: mockDisconnect, disconnect: mockDisconnect,
observe: jest.fn(), observe: jest.fn(),
})); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment