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
bde0f7aa
Commit
bde0f7aa
authored
6 years ago
by
Ben Wheeler
Browse files
Options
Downloads
Patches
Plain Diff
r
parent
f760e15e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/containers/sb-file-uploader.jsx
+1
-0
1 addition, 0 deletions
src/containers/sb-file-uploader.jsx
test/unit/containers/sb-file-uploader.test.jsx
+42
-34
42 additions, 34 deletions
test/unit/containers/sb-file-uploader.test.jsx
with
43 additions
and
34 deletions
src/containers/sb-file-uploader.jsx
+
1
−
0
View file @
bde0f7aa
...
@@ -41,6 +41,7 @@ class SBFileUploader extends React.Component {
...
@@ -41,6 +41,7 @@ class SBFileUploader extends React.Component {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
bindAll
(
this
,
[
bindAll
(
this
,
[
'
getProjectTitleFromFilename
'
,
'
renderFileInput
'
,
'
renderFileInput
'
,
'
setFileInput
'
,
'
setFileInput
'
,
'
handleChange
'
,
'
handleChange
'
,
...
...
This diff is collapsed.
Click to expand it.
test/unit/containers/sb-file-uploader.test.jsx
+
42
−
34
View file @
bde0f7aa
...
@@ -2,9 +2,12 @@ import React from 'react';
...
@@ -2,9 +2,12 @@ import React from 'react';
import
{
Provider
}
from
'
react-redux
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
{
mountWithIntl
,
shallowWithIntl
,
componentWithIntl
}
from
'
../../helpers/intl-helpers.jsx
'
;
import
{
mountWithIntl
,
shallowWithIntl
,
componentWithIntl
}
from
'
../../helpers/intl-helpers.jsx
'
;
import
configureStore
from
'
redux-mock-store
'
;
import
configureStore
from
'
redux-mock-store
'
;
import
SBFileUploader
from
'
../../../src/containers/sb-file-uploader.jsx
'
;
import
SBFileUploader
from
'
../../../src/containers/sb-file-uploader
'
;
import
{
LoadingState
}
from
'
../../../src/reducers/project-state
'
;
describe
(
'
SBFileUploader
'
,
()
=>
{
jest
.
mock
(
'
react-ga
'
);
// must mock this entire library, or lib/analytics causes error
describe
(
'
SBFileUploader Container
'
,
()
=>
{
const
mockStore
=
configureStore
();
const
mockStore
=
configureStore
();
let
onLoadingFinished
;
let
onLoadingFinished
;
let
onLoadingStarted
;
let
onLoadingStarted
;
...
@@ -14,25 +17,29 @@ describe('SBFileUploader', () => {
...
@@ -14,25 +17,29 @@ describe('SBFileUploader', () => {
// Wrap this in a function so it gets test specific states and can be reused.
// Wrap this in a function so it gets test specific states and can be reused.
const
getContainer
=
function
()
{
const
getContainer
=
function
()
{
return
(
return
(
<
SBFileUploader
<
Provider
store
=
{
store
}
>
store
=
{
store
}
<
SBFileUploader
onLoadingFinished
=
{
onLoadingFinished
}
onLoadingFinished
=
{
onLoadingFinished
}
onLoadingStarted
=
{
onLoadingStarted
}
onLoadingStarted
=
{
onLoadingStarted
}
onUpdateProjectTitle
=
{
onUpdateProjectTitle
}
onUpdateProjectTitle
=
{
onUpdateProjectTitle
}
>
>
{
(
renderFileInput
,
loadProject
)
=>
(
{
(
renderFileInput
,
loadProject
)
=>
(
<
div
<
div
onClick
=
{
loadProject
}
onClick
=
{
loadProject
}
/>
/>
)
}
)
}
</
SBFileUploader
>
</
SBFileUploader
>
</
Provider
>
);
);
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
=
mockStore
({
store
=
mockStore
({
scratchGui
:
{
scratchGui
:
{
projectState
:
{}
projectState
:
{
loadingState
:
LoadingState
.
SHOWING_WITH_ID
},
vm
:
{}
}
}
});
});
onUpdateProjectTitle
=
jest
.
fn
();
onUpdateProjectTitle
=
jest
.
fn
();
...
@@ -41,27 +48,28 @@ describe('SBFileUploader', () => {
...
@@ -41,27 +48,28 @@ describe('SBFileUploader', () => {
});
});
test
(
'
correctly sets title with .sb3 filename
'
,
()
=>
{
test
(
'
correctly sets title with .sb3 filename
'
,
()
=>
{
const
component
=
mountWithIntl
(
getContainer
());
const
wrapper
=
mountWithIntl
(
getContainer
());
const
instance
=
component
.
instance
();
const
instance
=
wrapper
.
find
(
SBFileUploader
).
component
();
expect
(
instance
).
toBe
(
true
);
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great.sb3
'
);
const
projectName
=
instance
.
getProjectTitleFromFilename
(
'
my project is great.sb3
'
);
expect
(
projectName
).
toBe
(
'
my project is great
'
);
expect
(
projectName
).
toBe
(
'
my project is great
'
);
});
});
test
(
'
correctly sets title with .sb3 filename
'
,
()
=>
{
//
test('correctly sets title with .sb3 filename', () => {
const
component
=
componentWithIntl
(
getContainer
());
//
const component = componentWithIntl(getContainer());
const
projectName
=
component
.
getProjectTitleFromFilename
(
'
my project is great.sb3
'
);
//
const projectName = component.getProjectTitleFromFilename('my project is great.sb3');
expect
(
projectName
).
toBe
(
'
my project is great
'
);
//
expect(projectName).toBe('my project is great');
});
//
});
//
test
(
'
sets blank title with .sb filename
'
,
()
=>
{
//
test('sets blank title with .sb filename', () => {
const
component
=
componentWithIntl
(
getContainer
());
//
const component = componentWithIntl(getContainer());
const
projectName
=
component
.
getProjectTitleFromFilename
(
'
my project is great.sb
'
);
//
const projectName = component.getProjectTitleFromFilename('my project is great.sb');
expect
(
projectName
).
toBe
(
''
);
//
expect(projectName).toBe('');
});
//
});
//
test
(
'
sets blank title with filename with no extension
'
,
()
=>
{
//
test('sets blank title with filename with no extension', () => {
const
component
=
componentWithIntl
(
getContainer
());
//
const component = componentWithIntl(getContainer());
const
projectName
=
component
.
getProjectTitleFromFilename
(
'
my project is great
'
);
//
const projectName = component.getProjectTitleFromFilename('my project is great');
expect
(
projectName
).
toBe
(
''
);
//
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