Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
df205124
Commit
df205124
authored
6 years ago
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Refactor ManifestListItem test to use a createWrapper helper
parent
09f250ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
__tests__/src/components/ManifestListItem.test.js
+23
-29
23 additions, 29 deletions
__tests__/src/components/ManifestListItem.test.js
with
23 additions
and
29 deletions
__tests__/src/components/ManifestListItem.test.js
+
23
−
29
View file @
df205124
...
...
@@ -2,60 +2,54 @@ import React from 'react';
import
{
shallow
}
from
'
enzyme
'
;
import
ManifestListItem
from
'
../../../src/components/ManifestListItem
'
;
describe
(
'
ManifestListItem
'
,
()
=>
{
it
(
'
renders without an error
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
/** */
function
createWrapper
(
props
)
{
return
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
title
=
"
xyz
"
ready
addWindow
=
{
addWindow
}
addWindow
=
{()
=>
{}}
fetchManifest
=
{()
=>
{}}
t
=
{
t
=>
t
}
{...
props
}
/>
,
).
dive
();
).
dive
();
// to unwrapp HOC created by withStyle()
}
describe
(
'
ManifestListItem
'
,
()
=>
{
it
(
'
renders without an error
'
,
()
=>
{
const
wrapper
=
createWrapper
();
expect
(
wrapper
.
find
(
'
.mirador-manifest-list-item
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
WithStyles(ButtonBase)
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
WithStyles(ButtonBase) WithStyles(Typography)
'
).
children
().
text
()).
toEqual
(
'
xyz
'
);
});
it
(
'
renders a placeholder element until real data is available
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
addWindow
=
{
addWindow
}
/>
,
).
dive
();
const
wrapper
=
createWrapper
({
ready
:
false
});
expect
(
wrapper
.
find
(
'
.mirador-manifest-list-item
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
ReactPlaceholder
'
).
length
).
toBe
(
1
);
});
it
(
'
updates and adds window when button clicked
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
title
=
"
xyz
"
addWindow
=
{
addWindow
}
/>
,
).
dive
();
const
wrapper
=
createWrapper
({
addWindow
});
wrapper
.
find
(
'
WithStyles(ButtonBase)
'
).
simulate
(
'
click
'
);
expect
(
addWindow
).
toHaveBeenCalledTimes
(
1
);
});
it
(
'
uses the manifest id if the title is not available
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
ready
addWindow
=
{
addWindow
}
/>
,
).
dive
();
const
wrapper
=
createWrapper
({
ready
:
true
,
title
:
null
});
expect
(
wrapper
.
find
(
'
WithStyles(ButtonBase)
'
).
length
).
toBe
(
1
);
expect
(
wrapper
.
find
(
'
WithStyles(ButtonBase) WithStyles(Typography)
'
).
children
().
text
()).
toEqual
(
'
http://example.com
'
);
});
it
(
'
displays the provider information
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
ready
provider
=
"
ACME
"
addWindow
=
{
addWindow
}
/>
,
).
dive
();
const
wrapper
=
createWrapper
({
provider
:
'
ACME
'
});
expect
(
wrapper
.
find
(
'
WithStyles(Typography).mirador-manifest-list-item-provider
'
).
children
().
text
()).
toEqual
(
'
ACME
'
);
});
it
(
'
displays a placeholder provider if no information is given
'
,
()
=>
{
const
addWindow
=
jest
.
fn
();
const
wrapper
=
shallow
(
<
ManifestListItem
manifestId
=
"
http://example.com
"
ready
addWindow
=
{
addWindow
}
/>
,
).
dive
();
const
wrapper
=
createWrapper
();
expect
(
wrapper
.
find
(
'
WithStyles(Typography).mirador-manifest-list-item-provider
'
).
children
().
text
()).
toEqual
(
'
addedFromUrl
'
);
});
});
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