-
-
Notifications
You must be signed in to change notification settings - Fork 79k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Collapse from './collapse' | ||
|
||
/** Test helpers */ | ||
import { getFixture, clearFixture } from '../../tests/helpers/fixture' | ||
|
||
describe('Collapse', () => { | ||
let fixtureEl | ||
|
||
beforeAll(() => { | ||
fixtureEl = getFixture() | ||
}) | ||
|
||
afterEach(() => { | ||
clearFixture() | ||
}) | ||
|
||
describe('VERSION', () => { | ||
it('should return plugin version', () => { | ||
expect(Collapse.VERSION).toEqual(jasmine.any(String)) | ||
}) | ||
}) | ||
|
||
describe('Default', () => { | ||
it('should return plugin default config', () => { | ||
expect(Collapse.Default).toEqual(jasmine.any(Object)) | ||
}) | ||
}) | ||
|
||
describe('toggle', () => { | ||
it('should call show method if show class is not present', () => { | ||
fixtureEl.innerHTML = '<div></div>' | ||
|
||
const collapseEl = fixtureEl.querySelector('div') | ||
const collapse = new Collapse(collapseEl) | ||
|
||
spyOn(collapse, 'show') | ||
|
||
collapse.toggle() | ||
|
||
expect(collapse.show).toHaveBeenCalled() | ||
}) | ||
|
||
it('should call hide method if show class is present', () => { | ||
fixtureEl.innerHTML = '<div class="show"></div>' | ||
|
||
const collapseEl = fixtureEl.querySelector('.show') | ||
const collapse = new Collapse(collapseEl, { | ||
toggle: false | ||
}) | ||
|
||
spyOn(collapse, 'hide') | ||
|
||
collapse.toggle() | ||
|
||
expect(collapse.hide).toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |