-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from CMDBrew/chore_eol_change
chore: change EOL to LF
- Loading branch information
Showing
2 changed files
with
82 additions
and
82 deletions.
There are no files selected for viewing
138 changes: 69 additions & 69 deletions
138
app/javascript/adminterface/lib/__tests__/detached_dropdown.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<div data-sortable="address"> | ||
<form class="has-many-list"> | ||
<fieldset class="has_many_fields"> | ||
<input type="checkbox" name="[_destroy]" checked> | ||
<input type="text" name="[address]" value="Tokyo"> | ||
<a class="button has_many_remove"></a> | ||
<a | ||
class="button has_many_add" | ||
data-html="<div></div>" | ||
data-placeholder="script" | ||
></a> | ||
</fieldset> | ||
</form> | ||
<div data-sortable="address"> | ||
<form class="has-many-list"> | ||
<fieldset class="has_many_fields"> | ||
<input type="checkbox" name="[_destroy]" checked> | ||
<input type="text" name="[address]" value="Tokyo"> | ||
<a class="button has_many_remove"></a> | ||
<a | ||
class="button has_many_add" | ||
data-html="<div></div>" | ||
data-placeholder="script" | ||
></a> | ||
</fieldset> | ||
</form> | ||
</div> |