forked from guonanci/react-images-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
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
37 changed files
with
1,492 additions
and
471 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
{ | ||
"ignore": ["node-modules/**"], | ||
"presets": ["env", "stage-2", "react"] | ||
"ignore": ["node-modules"], | ||
"presets": ["env", "react"], | ||
"plugins": [ ["transform-object-rest-spread", { "useBuiltIns": true }], "transform-object-assign"], | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
["env"], "react" | ||
], | ||
"plugins": ["istanbul"] | ||
} | ||
} | ||
} |
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,13 @@ | ||
|
||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
root = true | ||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
[*.md] | ||
trim_trailing_whitespace = false |
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,4 @@ | ||
lib/* | ||
dist/* | ||
coverage/* | ||
node_modules/* |
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 @@ | ||
examples |
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
Empty file.
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 React from 'react' | ||
import ImgsViewer from '../src/ImgsViewer' | ||
import { mount } from 'enzyme' | ||
|
||
const props1 = { | ||
imgs: [ | ||
{ | ||
src: 'https://images.unsplash.com/photo-1526382551041-3c817fc3d478?dpr=2&auto=format&w=1024&h=1024' | ||
}, | ||
{ | ||
src: 'https://images.unsplash.com/photo-1522985225914-17a10a58c8ec?dpr=2&auto=format&w=1024&h=1024', | ||
caption: 'Photo by Blake Cheek', | ||
} | ||
] | ||
} | ||
const props2 = { | ||
imgs: [ | ||
{ | ||
src: 'https://images.unsplash.com/photo-1522931698295-e7b4d3e4188f?dpr=2&auto=format&w=1024&h=1024', | ||
thumnail: 'https://images.unsplash.com/photo-1522931698295-e7b4d3e4188f?dpr=2&auto=format&crop=faces&fit=crop&w=300&h=300', | ||
}, | ||
{ | ||
src: 'https://images.unsplash.com/photo-1482398650355-d4c6462afa0e?dpr=2&auto=format&w=1024&h=1024', | ||
thumnail: 'https://images.unsplash.com/photo-1482398650355-d4c6462afa0e?dpr=2&auto=format&crop=faces&fit=crop&w=240&h=159', | ||
} | ||
] | ||
} | ||
it('renders correctly', () => { | ||
const component = mount( | ||
<ImgsViewer { ...props1 } /> | ||
) | ||
component.setState({ isOpen: true }) | ||
expect(component).toMatchSnapshot() | ||
}) | ||
it('renders with thumbnail correctly', () => { | ||
const component = mount( | ||
<ImgsViewer { ...props2 } /> | ||
) | ||
component.setState({ isOpen: true }) | ||
expect(component).toMatchSnapshot() | ||
}) | ||
it('renders correctly after click', () => { | ||
const component = mount( | ||
<ImgsViewer { ...props2 } /> | ||
) | ||
component.setState({ isOpen: true }) | ||
setTimeout(() => { | ||
component.find('figure').first() && component.find('figure').first().simulate('click') | ||
expect(component).toMatchSnapshot() | ||
}, 10000) | ||
}) | ||
it('unmount', () => { | ||
const component = mount( | ||
<ImgsViewer { ...props2 } /> | ||
) | ||
component.setState({ isOpen: true }) | ||
component.unmount() | ||
}) |
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,4 @@ | ||
import { configure } from 'enzyme' | ||
import Adapter from 'enzyme-adapter-react-16' | ||
|
||
configure({ adapter: new Adapter() }) |
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 @@ | ||
global.requestAnimationFrame = callback => setTimeout(callback, 0) |
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,29 @@ | ||
import { deepMerge, canUseDom, bindFunctions } from '../src/utils/util' | ||
|
||
describe('the deepMerge function', () => { | ||
test('merge numb, stri in one level', () => expect( | ||
deepMerge({ a: 1, b: 2 }, { a: '3', b: 4 })).toEqual({ a: '3', b: 4 }) | ||
) | ||
test('replace str with arr', () => expect( | ||
deepMerge({ a: 1 }, { a: ['3', 4] })).toEqual({ a: { 0: '3', 1: 4} }) | ||
) | ||
test('replace arr with obj', () => expect( | ||
deepMerge({ a: [1, 2] }, { a: { b: 1, c: '2' } })).toEqual({ a: { 0: 1, 1: 2, b: 1, c: '2' } }) | ||
) | ||
test('replace arr with obj', () => expect( | ||
deepMerge({ a: [1, 2] }, { a: { b: 1, c: '2' } })).toEqual({ a: { 0: 1, 1: 2, b: 1, c: '2' } }) | ||
) | ||
test('replace obj with obj', () => expect( | ||
deepMerge({ a: { b: 1 } }, { a: { b: '2' } })).toEqual({ a: { b: '2' } }) | ||
) | ||
test('replace arr with arr', () => expect( | ||
deepMerge({ a: [1] }, { a: { b: [2, 3] } })).toEqual({ a: { 0: 1, b: [2, 3] } }) | ||
) | ||
test('replace obj with num', () => expect( | ||
deepMerge({ a: 1 }, 2)).toEqual({ a: 1 }) | ||
) | ||
test('replace num with num', () => expect( | ||
deepMerge(1, 2)).toEqual({ }) | ||
) | ||
|
||
}) |
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
Oops, something went wrong.