Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
76e11e0e
Commit
76e11e0e
authored
6 years ago
by
Ben Wheeler
Browse files
Options
Downloads
Patches
Plain Diff
got sb-file-uploader tests working
parent
bde0f7aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unit/containers/sb-file-uploader.test.jsx
+47
-33
47 additions, 33 deletions
test/unit/containers/sb-file-uploader.test.jsx
with
47 additions
and
33 deletions
test/unit/containers/sb-file-uploader.test.jsx
+
47
−
33
View file @
76e11e0e
import
React
from
'
react
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
{
mount
,
shallow
}
from
'
enzyme
'
;
import
{
mountWithIntl
,
shallowWithIntl
,
componentWithIntl
}
from
'
../../helpers/intl-helpers.jsx
'
;
import
configureStore
from
'
redux-mock-store
'
;
import
SBFileUploader
from
'
../../../src/containers/sb-file-uploader
'
;
...
...
@@ -17,19 +19,17 @@ describe('SBFileUploader Container', () => {
// Wrap this in a function so it gets test specific states and can be reused.
const
getContainer
=
function
()
{
return
(
<
Provider
store
=
{
store
}
>
<
SBFileUploader
onLoadingFinished
=
{
onLoadingFinished
}
onLoadingStarted
=
{
onLoadingStarted
}
onUpdateProjectTitle
=
{
onUpdateProjectTitle
}
>
{
(
renderFileInput
,
loadProject
)
=>
(
<
div
onClick
=
{
loadProject
}
/>
)
}
</
SBFileUploader
>
</
Provider
>
<
SBFileUploader
onLoadingFinished
=
{
onLoadingFinished
}
onLoadingStarted
=
{
onLoadingStarted
}
onUpdateProjectTitle
=
{
onUpdateProjectTitle
}
>
{
(
renderFileInput
,
loadProject
)
=>
(
<
div
onClick
=
{
loadProject
}
/>
)
}
</
SBFileUploader
>
);
};
...
...
@@ -48,28 +48,42 @@ describe('SBFileUploader Container', () => {
});
test
(
'
correctly sets title with .sb3 filename
'
,
()
=>
{
const
wrapper
=
mountWithIntl
(
getContainer
());
const
instance
=
wrapper
.
find
(
SBFileUploader
).
component
();
expect
(
instance
).
toBe
(
true
);
const
wrapper
=
shallowWithIntl
(
getContainer
(),
{
context
:
{
store
}});
const
instance
=
wrapper
.
dive
()
// unwrap redux Connect(InjectIntl(SBFileUploader))
.
dive
()
// unwrap InjectIntl(SBFileUploader)
.
instance
();
// SBFileUploader
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great.sb3
'
);
expect
(
projectName
).
toBe
(
'
my project is great
'
);
});
// test('correctly sets title with .sb3 filename', () => {
// const component = componentWithIntl(getContainer());
// const projectName = component.getProjectTitleFromFilename('my project is great.sb3');
// expect(projectName).toBe('my project is great');
// });
//
// test('sets blank title with .sb filename', () => {
// const component = componentWithIntl(getContainer());
// const projectName = component.getProjectTitleFromFilename('my project is great.sb');
// expect(projectName).toBe('');
// });
//
// test('sets blank title with filename with no extension', () => {
// const component = componentWithIntl(getContainer());
// const projectName = component.getProjectTitleFromFilename('my project is great');
// expect(projectName).toBe('');
// });
test
(
'
correctly sets title with .sb2 filename
'
,
()
=>
{
const
wrapper
=
shallowWithIntl
(
getContainer
(),
{
context
:
{
store
}});
const
instance
=
wrapper
.
dive
()
// unwrap redux Connect(InjectIntl(SBFileUploader))
.
dive
()
// unwrap InjectIntl(SBFileUploader)
.
instance
();
// SBFileUploader
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great.sb2
'
);
expect
(
projectName
).
toBe
(
'
my project is great
'
);
});
test
(
'
sets blank title with .sb filename
'
,
()
=>
{
const
wrapper
=
shallowWithIntl
(
getContainer
(),
{
context
:
{
store
}});
const
instance
=
wrapper
.
dive
()
// unwrap redux Connect(InjectIntl(SBFileUploader))
.
dive
()
// unwrap InjectIntl(SBFileUploader)
.
instance
();
// SBFileUploader
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great.sb
'
);
expect
(
projectName
).
toBe
(
''
);
});
test
(
'
sets blank title with filename with no extension
'
,
()
=>
{
const
wrapper
=
shallowWithIntl
(
getContainer
(),
{
context
:
{
store
}});
const
instance
=
wrapper
.
dive
()
// unwrap redux Connect(InjectIntl(SBFileUploader))
.
dive
()
// unwrap InjectIntl(SBFileUploader)
.
instance
();
// SBFileUploader
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great
'
);
expect
(
projectName
).
toBe
(
''
);
});
});
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