Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
fe502753
Commit
fe502753
authored
Apr 07, 2017
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more complete tests for `updateFlagStatus` action
parent
80057535
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
+42
-26
annotations-test.js
src/sidebar/reducers/test/annotations-test.js
+42
-26
No files found.
src/sidebar/reducers/test/annotations-test.js
View file @
fe502753
...
...
@@ -86,35 +86,51 @@ describe('annotations reducer', function () {
unroll
(
'updates the flagged status of an annotation'
,
function
(
testCase
)
{
var
store
=
createStore
();
var
ann
=
fixtures
.
defaultAnnotation
();
ann
.
flagged
=
!
testCase
.
flagged
;
ann
.
flagged
=
testCase
.
wasFlagged
;
ann
.
moderation
=
testCase
.
oldModeration
;
store
.
dispatch
(
actions
.
addAnnotations
([
ann
]));
store
.
dispatch
(
actions
.
updateFlagStatus
(
ann
.
id
,
testCase
.
f
lagged
));
store
.
dispatch
(
actions
.
updateFlagStatus
(
ann
.
id
,
testCase
.
nowF
lagged
));
var
storeAnn
=
annotations
.
findAnnotationByID
(
store
.
getState
(),
ann
.
id
);
assert
.
equal
(
storeAnn
.
flagged
,
testCase
.
flagged
);
},
[{
flagged
:
true
},
{
flagged
:
false
}]);
it
(
'does not add moderation info if not present'
,
function
()
{
var
store
=
createStore
();
var
ann
=
fixtures
.
defaultAnnotation
();
store
.
dispatch
(
actions
.
addAnnotations
([
ann
]));
store
.
dispatch
(
actions
.
updateFlagStatus
(
ann
.
id
,
true
));
var
storeAnn
=
annotations
.
findAnnotationByID
(
store
.
getState
(),
ann
.
id
);
assert
.
notOk
(
storeAnn
.
moderation
);
});
it
(
'increments the flag count if moderation info is present'
,
function
()
{
var
store
=
createStore
();
var
ann
=
fixtures
.
moderatedAnnotation
({
flagCount
:
0
});
store
.
dispatch
(
actions
.
addAnnotations
([
ann
]));
store
.
dispatch
(
actions
.
updateFlagStatus
(
ann
.
id
,
true
));
var
storeAnn
=
annotations
.
findAnnotationByID
(
store
.
getState
(),
ann
.
id
);
assert
.
equal
(
storeAnn
.
moderation
.
flagCount
,
1
);
});
assert
.
equal
(
storeAnn
.
flagged
,
testCase
.
nowFlagged
);
assert
.
deepEqual
(
storeAnn
.
moderation
,
testCase
.
newModeration
);
},
[{
// Non-moderator flags annotation
wasFlagged
:
false
,
nowFlagged
:
true
,
oldModeration
:
undefined
,
newModeration
:
undefined
,
},
{
// Non-moderator un-flags annotation
wasFlagged
:
true
,
nowFlagged
:
false
,
oldModeration
:
undefined
,
newModeration
:
undefined
,
},{
// Moderator un-flags an already unflagged annotation
wasFlagged
:
false
,
nowFlagged
:
false
,
oldModeration
:
{
flagCount
:
1
},
newModeration
:
{
flagCount
:
1
},
},{
// Moderator flags an already flagged annotation
wasFlagged
:
true
,
nowFlagged
:
true
,
oldModeration
:
{
flagCount
:
1
},
newModeration
:
{
flagCount
:
1
},
},{
// Moderator flags annotation
wasFlagged
:
false
,
nowFlagged
:
true
,
oldModeration
:
{
flagCount
:
0
},
newModeration
:
{
flagCount
:
1
},
},{
// Moderator un-flags annotation
wasFlagged
:
true
,
nowFlagged
:
false
,
oldModeration
:
{
flagCount
:
1
},
newModeration
:
{
flagCount
:
0
},
}]);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment