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
50265fe8
Commit
50265fe8
authored
5 years ago
by
Ben Wheeler
Browse files
Options
Downloads
Patches
Plain Diff
added tests for project loading states
parent
461877b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unit/reducers/project-state-reducer.test.js
+65
-19
65 additions, 19 deletions
test/unit/reducers/project-state-reducer.test.js
with
65 additions
and
19 deletions
test/unit/reducers/project-state-reducer.test.js
+
65
−
19
View file @
50265fe8
...
@@ -92,16 +92,49 @@ test('onFetchedProjectData new loads project data into vm', () => {
...
@@ -92,16 +92,49 @@ test('onFetchedProjectData new loads project data into vm', () => {
expect
(
resultState
.
projectData
).
toBe
(
'
1010101
'
);
expect
(
resultState
.
projectData
).
toBe
(
'
1010101
'
);
});
});
test
(
'
onLoadedProject upload, with canSave false, shows without id
'
,
()
=>
{
// onLoadedProject: LOADING_VM_WITH_ID
test
(
'
onLoadedProject (LOADING_VM_WITH_ID, true, true) shows with id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_
FILE_UPLOA
D
loadingState
:
LoadingState
.
LOADING_VM_
WITH_I
D
};
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
true
);
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
true
,
true
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
});
test
(
'
onLoadedProject (LOADING_VM_WITH_ID, false, true) shows with id
'
,
()
=>
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_WITH_ID
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
true
,
true
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
});
test
(
'
onLoadedProject (LOADING_VM_WITH_ID, false, false), with project id, shows with id
'
,
()
=>
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_WITH_ID
,
projectId
:
'
12345
'
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
false
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
});
test
(
'
onLoadedProject (LOADING_VM_WITH_ID, false, false), with no project id, shows without id
'
,
()
=>
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_WITH_ID
,
projectId
:
null
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
false
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
});
});
test
(
'
onLoadedProject upload, with canSave true, prepares to save
'
,
()
=>
{
// onLoadedProject: LOADING_VM_FILE_UPLOAD
test
(
'
onLoadedProject(LOADING_VM_FILE_UPLOAD, true, true) prepares to save
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_FILE_UPLOAD
loadingState
:
LoadingState
.
LOADING_VM_FILE_UPLOAD
};
};
...
@@ -110,25 +143,38 @@ test('onLoadedProject upload, with canSave true, prepares to save', () => {
...
@@ -110,25 +143,38 @@ test('onLoadedProject upload, with canSave true, prepares to save', () => {
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
AUTO_UPDATING
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
AUTO_UPDATING
);
});
});
test
(
'
onLoadedProject
with id
shows with id
'
,
()
=>
{
test
(
'
onLoadedProject
(LOADING_VM_FILE_UPLOAD, false, true)
shows with
out
id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_
WITH_I
D
loadingState
:
LoadingState
.
LOADING_VM_
FILE_UPLOA
D
};
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
true
,
true
);
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
true
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
});
test
(
'
onLoadedProject (LOADING_VM_FILE_UPLOAD, false, false), with project id, shows with id
'
,
()
=>
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_FILE_UPLOAD
,
projectId
:
'
12345
'
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
false
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
});
});
test
(
'
onLoadedProject
new
shows without id
'
,
()
=>
{
test
(
'
onLoadedProject
(LOADING_VM_FILE_UPLOAD, false, false), with no project id,
shows without id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_NEW_DEFAULT
loadingState
:
LoadingState
.
LOADING_VM_FILE_UPLOAD
,
projectId
:
null
};
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
tru
e
);
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
fals
e
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
});
});
test
(
'
onLoadedProject new, to save shows without id
'
,
()
=>
{
// onLoadedProject: LOADING_VM_NEW_DEFAULT
test
(
'
onLoadedProject (LOADING_VM_NEW_DEFAULT, true, true) shows without id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_NEW_DEFAULT
loadingState
:
LoadingState
.
LOADING_VM_NEW_DEFAULT
};
};
...
@@ -137,26 +183,26 @@ test('onLoadedProject new, to save shows without id', () => {
...
@@ -137,26 +183,26 @@ test('onLoadedProject new, to save shows without id', () => {
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
});
});
test
(
'
onLoadedProject
with success false, no project id,
shows without id
'
,
()
=>
{
test
(
'
onLoadedProject
(LOADING_VM_NEW_DEFAULT, false, true)
shows without id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_WITH_ID
,
loadingState
:
LoadingState
.
LOADING_VM_NEW_DEFAULT
projectId
:
null
};
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
fals
e
);
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
tru
e
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITHOUT_ID
);
});
});
test
(
'
onLoadedProject
with success
false,
v
al
id project id, shows with id
'
,
()
=>
{
test
(
'
onLoadedProject
(LOADING_VM_NEW_DEFAULT,
false,
f
al
se) shows error
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
LOADING_VM_WITH_ID
,
loadingState
:
LoadingState
.
LOADING_VM_NEW_DEFAULT
projectId
:
'
12345
'
};
};
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
false
);
const
action
=
onLoadedProject
(
initialState
.
loadingState
,
false
,
false
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
const
resultState
=
projectStateReducer
(
initialState
,
action
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
SHOWING_WITH_ID
);
expect
(
resultState
.
loadingState
).
toBe
(
LoadingState
.
ERROR
);
});
});
// doneUpdatingProject
test
(
'
doneUpdatingProject with id shows with id
'
,
()
=>
{
test
(
'
doneUpdatingProject with id shows with id
'
,
()
=>
{
const
initialState
=
{
const
initialState
=
{
loadingState
:
LoadingState
.
MANUAL_UPDATING
loadingState
:
LoadingState
.
MANUAL_UPDATING
...
...
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