chore(auto-submit-button): implemented destroy in auto-submit-button
This commit is contained in:
parent
780a5f7ce1
commit
3e01c8d910
@ -9,8 +9,10 @@ const AUTO_SUBMIT_BUTTON_HIDDEN_CLASS = 'hidden';
|
||||
selector: AUTO_SUBMIT_BUTTON_UTIL_SELECTOR,
|
||||
})
|
||||
export class AutoSubmitButton {
|
||||
_element;
|
||||
|
||||
constructor(element) {
|
||||
this._element = element;
|
||||
if (!element) {
|
||||
throw new Error('Auto Submit Button utility needs to be passed an element!');
|
||||
}
|
||||
@ -24,6 +26,7 @@ export class AutoSubmitButton {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// TODO
|
||||
this._element.classList.remove(AUTO_SUBMIT_BUTTON_INITIALIZED_CLASS);
|
||||
this._element.classList.remove(AUTO_SUBMIT_BUTTON_HIDDEN_CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
27
frontend/src/utils/form/auto-submit-button.spec.js
Normal file
27
frontend/src/utils/form/auto-submit-button.spec.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { AutoSubmitButton, AUTO_SUBMIT_BUTTON_INITIALIZED_CLASS, AUTO_SUBMIT_BUTTON_HIDDEN_CLASS } from './auto-submit-button.js';
|
||||
|
||||
describe('Auto-submit-button', () => {
|
||||
|
||||
let autoSubmitButton;
|
||||
|
||||
beforeEach(() => {
|
||||
const element = document.createElement('div');
|
||||
autoSubmitButton = new AutoSubmitButton(element);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(autoSubmitButton).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should destory auto-submit-button', () => {
|
||||
autoSubmitButton.destroy();
|
||||
expect(autoSubmitButton._element.classList).not.toContain(AUTO_SUBMIT_BUTTON_INITIALIZED_CLASS);
|
||||
expect(autoSubmitButton._element.classList).not.toContain(AUTO_SUBMIT_BUTTON_HIDDEN_CLASS);
|
||||
});
|
||||
|
||||
it('should throw if called without an element', () => {
|
||||
expect(() => {
|
||||
new AutoSubmitButton();
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user