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
1 parent
7145633
commit 7a90e8b
Showing
8 changed files
with
4,045 additions
and
900 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`hide hide() renders correctly 1`] = ` | ||
<body> | ||
<img | ||
class="medium-zoom-image" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`mediumZoom init with only an option object attaches scaled images and applies options 1`] = ` | ||
<body> | ||
<img | ||
class="medium-zoom-image" | ||
width="200" | ||
/> | ||
<img /> | ||
<p /> | ||
</body> | ||
`; | ||
|
||
exports[`show show() renders correctly 1`] = ` | ||
<body> | ||
<img | ||
class="medium-zoom-image medium-zoom-image--open" | ||
/> | ||
<div | ||
class="medium-zoom-overlay" | ||
style="background-color: rgb(255, 255, 255);" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`show show() renders correctly with options overlay background 1`] = ` | ||
<body> | ||
<img | ||
class="medium-zoom-image medium-zoom-image--open" | ||
/> | ||
<div | ||
class="medium-zoom-overlay" | ||
style="background-color: rgb(186, 218, 85);" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`update update() background updates the background option, returns all options and renders correctly 1`] = ` | ||
<body> | ||
<img | ||
class="medium-zoom-image medium-zoom-image--open" | ||
/> | ||
<div | ||
class="medium-zoom-overlay" | ||
style="background-color: rgb(0, 0, 0);" | ||
/> | ||
</body> | ||
`; |
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,38 @@ | ||
/* eslint-env jest */ | ||
const mediumZoom = require('../medium-zoom') | ||
|
||
global.requestAnimationFrame = cb => setTimeout(cb, 0) | ||
|
||
describe('click', () => { | ||
const root = document.body | ||
|
||
beforeEach(() => { | ||
while (root.firstChild) { | ||
root.removeChild(root.firstChild) | ||
} | ||
}) | ||
|
||
test('click on an image should add classes', () => { | ||
const image = document.createElement('img') | ||
root.appendChild(image) | ||
|
||
mediumZoom('img') | ||
|
||
image.click() | ||
const classNames = [...image.classList] | ||
|
||
expect(classNames).toEqual(['medium-zoom-image', 'medium-zoom-image--open']) | ||
}) | ||
|
||
test('click on a detached image should not add classes', () => { | ||
const image = document.createElement('img') | ||
root.appendChild(image) | ||
|
||
const zoom = mediumZoom('img') | ||
zoom.detach() | ||
|
||
image.click() | ||
|
||
expect(image.classList).toHaveLength(0) | ||
}) | ||
}) |
Oops, something went wrong.