diff --git a/app/javascript/adminterface/lib/__tests__/detached_dropdown.spec.js b/app/javascript/adminterface/lib/__tests__/detached_dropdown.spec.js index a7229cb5..7bccd08d 100644 --- a/app/javascript/adminterface/lib/__tests__/detached_dropdown.spec.js +++ b/app/javascript/adminterface/lib/__tests__/detached_dropdown.spec.js @@ -1,69 +1,69 @@ -import DetachedDropdownClass from '../detached_dropdown' - -describe('DetachedDropdown', () => { - const element = document.createElement('div') - const options = { - title: '.title-menu' - } - - beforeEach(() => { - global.adminterface = { - addObserver: jest.fn() - } - }) - - test('constructor initiates properties and call bind correctly', () => { - const spyOnBind = jest.spyOn(DetachedDropdownClass.prototype, '_bind') - spyOnBind.mockImplementation(() => {}) - const DetachedDropdown = new DetachedDropdownClass(element, options) - - expect(DetachedDropdown.element).toEqual(element) - expect(DetachedDropdown.options).toEqual({ - menu: '.dropdown-menu', - ...options - }) - expect(spyOnBind).toHaveBeenCalledTimes(1) - spyOnBind.mockRestore() - }) - - test('bind method calls adminterface correctly', () => { - const DetachedDropdown = new DetachedDropdownClass(element, options) - - expect(global.adminterface.addObserver).toHaveBeenCalledWith( - element, - DetachedDropdown, - DetachedDropdown.constructor.name - ) - }) - - test('bind method add event listener correctly', () => { - const DetachedDropdown = new DetachedDropdownClass(element, options) - const spyOnAddEventListener = jest.spyOn( - DetachedDropdown.element, - 'addEventListener' - ) - DetachedDropdown._bind() - - expect(spyOnAddEventListener).toHaveBeenCalledTimes(2) - expect(spyOnAddEventListener.mock.calls).toEqual([ - ['show.bs.dropdown', expect.any(Function)], - ['hidden.bs.dropdown', expect.any(Function)] - ]) - }) - - test('append method calls native WEB API append correctly', () => { - const testDiv = document.createElement('div') - const testP = document.createElement('p') - testDiv.append('Some text', testP) - - const DetachedDropdown = new DetachedDropdownClass(element, options) - const spyOnAppend = jest.spyOn(document.body, 'append') - - DetachedDropdown._append(document.body, testP) - - expect(spyOnAppend).toHaveBeenCalledTimes(1) - expect(spyOnAppend).toHaveBeenCalledWith( - testP.parentElement.removeChild(testP) - ) - }) -}) +import DetachedDropdownClass from '../detached_dropdown' + +describe('DetachedDropdown', () => { + const element = document.createElement('div') + const options = { + title: '.title-menu' + } + + beforeEach(() => { + global.adminterface = { + addObserver: jest.fn() + } + }) + + test('constructor initiates properties and call bind correctly', () => { + const spyOnBind = jest.spyOn(DetachedDropdownClass.prototype, '_bind') + spyOnBind.mockImplementation(() => {}) + const DetachedDropdown = new DetachedDropdownClass(element, options) + + expect(DetachedDropdown.element).toEqual(element) + expect(DetachedDropdown.options).toEqual({ + menu: '.dropdown-menu', + ...options + }) + expect(spyOnBind).toHaveBeenCalledTimes(1) + spyOnBind.mockRestore() + }) + + test('bind method calls adminterface correctly', () => { + const DetachedDropdown = new DetachedDropdownClass(element, options) + + expect(global.adminterface.addObserver).toHaveBeenCalledWith( + element, + DetachedDropdown, + DetachedDropdown.constructor.name + ) + }) + + test('bind method add event listener correctly', () => { + const DetachedDropdown = new DetachedDropdownClass(element, options) + const spyOnAddEventListener = jest.spyOn( + DetachedDropdown.element, + 'addEventListener' + ) + DetachedDropdown._bind() + + expect(spyOnAddEventListener).toHaveBeenCalledTimes(2) + expect(spyOnAddEventListener.mock.calls).toEqual([ + ['show.bs.dropdown', expect.any(Function)], + ['hidden.bs.dropdown', expect.any(Function)] + ]) + }) + + test('append method calls native WEB API append correctly', () => { + const testDiv = document.createElement('div') + const testP = document.createElement('p') + testDiv.append('Some text', testP) + + const DetachedDropdown = new DetachedDropdownClass(element, options) + const spyOnAppend = jest.spyOn(document.body, 'append') + + DetachedDropdown._append(document.body, testP) + + expect(spyOnAppend).toHaveBeenCalledTimes(1) + expect(spyOnAppend).toHaveBeenCalledWith( + testP.parentElement.removeChild(testP) + ) + }) +}) diff --git a/app/javascript/adminterface/lib/__tests__/has_many.html b/app/javascript/adminterface/lib/__tests__/has_many.html index cee83d0e..a59f1925 100644 --- a/app/javascript/adminterface/lib/__tests__/has_many.html +++ b/app/javascript/adminterface/lib/__tests__/has_many.html @@ -1,14 +1,14 @@ -