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
9eff42c0
Commit
9eff42c0
authored
6 years ago
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Refactor WorkspaceMosaic tests to use a createWrapper helper
parent
5201f5b8
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/WorkspaceMosaic.test.js
+19
-30
19 additions, 30 deletions
__tests__/src/components/WorkspaceMosaic.test.js
with
19 additions
and
30 deletions
__tests__/src/components/WorkspaceMosaic.test.js
+
19
−
30
View file @
9eff42c0
...
...
@@ -3,17 +3,23 @@ import { shallow } from 'enzyme';
import
{
Mosaic
}
from
'
react-mosaic-component
'
;
import
WorkspaceMosaic
from
'
../../../src/components/WorkspaceMosaic
'
;
describe
(
'
WorkspaceMosaic
'
,
()
=>
{
const
windows
=
{
1
:
{
id
:
1
},
2
:
{
id
:
2
}
};
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
shallow
(
/** create wrapper */
function
createWrapper
(
props
)
{
return
shallow
(
<
WorkspaceMosaic
windows
=
{
windows
}
windows
=
{
{}
}
workspace
=
{{}}
updateWorkspaceMosaicLayout
=
{()
=>
{}}
{...
props
}
/>
,
);
}
describe
(
'
WorkspaceMosaic
'
,
()
=>
{
const
windows
=
{
1
:
{
id
:
1
},
2
:
{
id
:
2
}
};
let
wrapper
;
beforeEach
(()
=>
{
wrapper
=
createWrapper
({
windows
});
});
it
(
'
should render properly with an initialValue
'
,
()
=>
{
expect
(
wrapper
.
matchesElement
(
...
...
@@ -22,25 +28,13 @@ describe('WorkspaceMosaic', () => {
});
describe
(
'
determineWorkspaceLayout
'
,
()
=>
{
it
(
'
when window ids do not match workspace layout
'
,
()
=>
{
wrapper
=
shallow
(
<
WorkspaceMosaic
windows
=
{
windows
}
workspace
=
{{
layout
:
'
foo
'
}}
updateWorkspaceMosaicLayout
=
{()
=>
{}}
/>
,
);
wrapper
=
createWrapper
({
windows
,
workspace
:
{
layout
:
'
foo
'
}
});
expect
(
wrapper
.
instance
().
determineWorkspaceLayout
()).
toMatchObject
({
direction
:
'
row
'
,
first
:
'
1
'
,
second
:
'
2
'
,
});
});
it
(
'
when window ids match workspace layout
'
,
()
=>
{
wrapper
=
shallow
(
<
WorkspaceMosaic
windows
=
{{
foo
:
{
id
:
'
foo
'
}
}}
workspace
=
{{
layout
:
'
foo
'
}}
updateWorkspaceMosaicLayout
=
{()
=>
{}}
/>
,
);
wrapper
=
createWrapper
({
windows
:
{
foo
:
{
id
:
'
foo
'
}
},
workspace
:
{
layout
:
'
foo
'
}
});
expect
(
wrapper
.
instance
().
determineWorkspaceLayout
()).
toBeNull
();
});
});
...
...
@@ -54,16 +48,11 @@ describe('WorkspaceMosaic', () => {
});
describe
(
'
mosaicChange
'
,
()
=>
{
it
(
'
calls the provided prop to update layout
'
,
()
=>
{
const
mock
=
jest
.
fn
();
wrapper
=
shallow
(
<
WorkspaceMosaic
windows
=
{{
foo
:
{
id
:
'
foo
'
}
}}
workspace
=
{{
layout
:
'
foo
'
}}
updateWorkspaceMosaicLayout
=
{
mock
}
/>
,
);
const
updateWorkspaceMosaicLayout
=
jest
.
fn
();
wrapper
=
createWrapper
({
windows
,
updateWorkspaceMosaicLayout
});
wrapper
.
instance
().
mosaicChange
();
expect
(
mock
).
toBeCalled
();
expect
(
updateWorkspaceMosaicLayout
).
toBeCalled
();
});
});
});
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