Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mirador-video-annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Loïs Poujade
mirador-video-annotations
Commits
f72dc631
Commit
f72dc631
authored
Nov 14, 2018
by
Andrew Winget (Standard)
Browse files
Options
Downloads
Patches
Plain Diff
modify tests to begin testing lifecycle methods
parent
72870555
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
__tests__/src/actions/index.test.js
+1
-1
1 addition, 1 deletion
__tests__/src/actions/index.test.js
__tests__/src/components/Window.test.js
+5
-3
5 additions, 3 deletions
__tests__/src/components/Window.test.js
setupJest.js
+21
-0
21 additions, 0 deletions
setupJest.js
with
27 additions
and
4 deletions
__tests__/src/actions/index.test.js
+
1
−
1
View file @
f72dc631
...
...
@@ -23,7 +23,7 @@ describe('actions', () => {
collectionIndex
:
0
,
manifestId
:
null
,
rangeId
:
null
,
xywh
:
[
0
,
0
,
2
00
,
2
00
],
xywh
:
[
0
,
0
,
4
00
,
4
00
],
rotation
:
null
,
},
};
...
...
This diff is collapsed.
Click to expand it.
__tests__/src/components/Window.test.js
+
5
−
3
View file @
f72dc631
import
React
from
'
react
'
;
import
{
shallow
}
from
'
enzyme
'
;
import
{
mount
}
from
'
enzyme
'
;
import
{
actions
,
store
}
from
'
../../../src/store
'
;
import
Window
from
'
../../../src/components/Window
'
;
import
fixture
from
'
../../fixtures/2.json
'
;
...
...
@@ -11,11 +11,13 @@ describe('Window', () => {
store
.
dispatch
(
actions
.
receiveManifest
(
'
foo
'
,
fixture
));
store
.
dispatch
(
actions
.
addWindow
({
manifestId
:
'
foo
'
}));
[
window
]
=
store
.
getState
().
windows
;
wrapper
=
shallow
(
<
Window
store
=
{
store
}
id
=
{
window
.
id
}
/>
)
.dive
()
;
wrapper
=
mount
(
<
Window
store
=
{
store
}
id
=
{
window
.
id
}
/>
)
;
});
it
(
'
returns the width and height style attribute
'
,
()
=>
{
expect
(
wrapper
.
instance
().
styleAttributes
()).
toEqual
({
width
:
'
400px
'
,
height
:
'
400px
'
});
console
.
log
(
"
IT's HEEEEEEEEEEEEEEEEEERE!
"
);
console
.
log
(
wrapper
.
debug
());
expect
(
wrapper
.
ref
(
'
div
'
).
styleAttributes
()).
toEqual
({
width
:
'
400px
'
,
height
:
'
400px
'
});
});
it
(
'
renders without an error
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
setupJest.js
+
21
−
0
View file @
f72dc631
// Setup Jest to mock fetch
import
{
JSDOM
}
from
'
jsdom
'
;
// import jsdom for tests on code that is not fully-managed by react (openseadragon, for instance)
import
fetch
from
'
jest-fetch-mock
'
;
// eslint-disable-line import/no-extraneous-dependencies
import
Enzyme
from
'
enzyme
'
;
// eslint-disable-line import/no-extraneous-dependencies
import
Adapter
from
'
enzyme-adapter-react-16
'
;
// eslint-disable-line import/no-extraneous-dependencies
const
jsdom
=
new
JSDOM
(
'
<!doctype html><html><body></body></html>
'
);
const
{
window
}
=
jsdom
;
function
copyProps
(
src
,
target
)
{
const
props
=
Object
.
getOwnPropertyNames
(
src
)
.
filter
(
prop
=>
typeof
target
[
prop
]
===
'
undefined
'
)
.
reduce
((
result
,
prop
)
=>
({
...
result
,
[
prop
]:
Object
.
getOwnPropertyDescriptor
(
src
,
prop
),
}),
{});
Object
.
defineProperties
(
target
,
props
);
}
jest
.
setMock
(
'
node-fetch
'
,
fetch
);
global
.
fetch
=
require
(
'
jest-fetch-mock
'
);
// eslint-disable-line import/no-extraneous-dependencies
global
.
window
=
window
;
global
.
document
=
window
.
document
;
global
.
navigator
=
{
userAgent
:
'
node.js
'
,
};
copyProps
(
window
,
global
);
Enzyme
.
configure
({
adapter
:
new
Adapter
()
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment