Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cbddad5a
Commit
cbddad5a
authored
Aug 11, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tests for mutations and getters
parent
cedee012
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
192 additions
and
98 deletions
+192
-98
app/assets/javascripts/notes/components/issue_note_actions.vue
...ssets/javascripts/notes/components/issue_note_actions.vue
+1
-1
app/assets/javascripts/notes/components/issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+1
-1
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+1
-1
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+0
-1
spec/javascripts/notes/components/issue_note_app_spec.js
spec/javascripts/notes/components/issue_note_app_spec.js
+0
-13
spec/javascripts/notes/components/issue_note_form_spec.js
spec/javascripts/notes/components/issue_note_form_spec.js
+46
-34
spec/javascripts/notes/stores/getters_spec.js
spec/javascripts/notes/stores/getters_spec.js
+21
-33
spec/javascripts/notes/stores/mutation_spec.js
spec/javascripts/notes/stores/mutation_spec.js
+122
-14
No files found.
app/assets/javascripts/notes/components/issue_note_actions.vue
View file @
cbddad5a
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
this
.
emojiSmiling
=
emojiSmiling
;
this
.
emojiSmiling
=
emojiSmiling
;
this
.
emojiSmile
=
emojiSmile
;
this
.
emojiSmile
=
emojiSmile
;
this
.
emojiSmiley
=
emojiSmiley
;
this
.
emojiSmiley
=
emojiSmiley
;
}
}
,
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/notes/components/issue_note_awards_list.vue
View file @
cbddad5a
...
@@ -143,7 +143,7 @@
...
@@ -143,7 +143,7 @@
let
parsedName
;
let
parsedName
;
// 100 and 1234 emoji are a number. Callback for v-for click sends it as a string
// 100 and 1234 emoji are a number. Callback for v-for click sends it as a string
switch
(
awardName
)
{
switch
(
awardName
)
{
case
'
100
'
:
case
'
100
'
:
parsedName
=
100
;
parsedName
=
100
;
break
;
break
;
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
cbddad5a
...
@@ -152,7 +152,7 @@
...
@@ -152,7 +152,7 @@
</button>
</button>
<button
<button
@
click=
"cancelHandler()"
@
click=
"cancelHandler()"
class=
"btn btn-
nr btn-
cancel note-edit-cancel"
class=
"btn btn-cancel note-edit-cancel"
type=
"button"
>
type=
"button"
>
Cancel
Cancel
</button>
</button>
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
cbddad5a
...
@@ -46,7 +46,6 @@
...
@@ -46,7 +46,6 @@
computed
:
{
computed
:
{
...
mapGetters
([
...
mapGetters
([
'
notes
'
,
'
notes
'
,
'
notesById
'
,
'
getNotesDataByProp
'
,
'
getNotesDataByProp
'
,
]),
]),
},
},
...
...
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
cbddad5a
...
@@ -252,17 +252,4 @@ describe('issue_note_app', () => {
...
@@ -252,17 +252,4 @@ describe('issue_note_app', () => {
},
0
);
},
0
);
});
});
});
});
// TODO: FILIPA
describe
(
'
create new note
'
,
()
=>
{
it
(
'
should show placeholder note while new comment is being posted
'
,
()
=>
{});
it
(
'
should remove placeholder note when new comment is done posting
'
,
()
=>
{});
it
(
'
should show actual note element when new comment is done posting
'
,
()
=>
{});
it
(
'
should show flash error message when new comment failed to be posted
'
,
()
=>
{});
it
(
'
should show flash error message when comment failed to be updated
'
,
()
=>
{});
});
describe
(
'
shortcuts issuable spec
'
,
()
=>
{
});
});
});
spec/javascripts/notes/components/issue_note_form_spec.js
View file @
cbddad5a
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
store
from
'
~/notes/stores
'
;
import
store
from
'
~/notes/stores
'
;
import
issueNote
from
'
~/notes/components/issue_note
.vue
'
;
import
issueNote
Form
from
'
~/notes/components/issue_note_form
.vue
'
;
import
{
issueDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
issueDataMock
,
notesDataMock
}
from
'
../mock_data
'
;
import
{
keyboardDownEvent
}
from
'
../../issue_show/helpers
'
;
f
describe
(
'
issue_note_form component
'
,
()
=>
{
describe
(
'
issue_note_form component
'
,
()
=>
{
let
vm
;
let
vm
;
let
props
;
let
props
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
issueNote
);
const
Component
=
Vue
.
extend
(
issueNote
Form
);
store
.
dispatch
(
'
setIssueData
'
,
issueDataMock
);
store
.
dispatch
(
'
setIssueData
'
,
issueDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
props
=
{
props
=
{
isEditing
:
tru
e
,
isEditing
:
fals
e
,
noteBody
:
'
Magni suscipit eius consectetur enim et ex et commodi.
'
,
noteBody
:
'
Magni suscipit eius consectetur enim et ex et commodi.
'
,
noteId
:
545
,
noteId
:
545
,
saveButtonTitle
:
'
Save comment
'
,
};
};
vm
=
new
Component
({
vm
=
new
Component
({
...
@@ -30,13 +30,16 @@ fdescribe('issue_note_form component', () => {
...
@@ -30,13 +30,16 @@ fdescribe('issue_note_form component', () => {
vm
.
$destroy
();
vm
.
$destroy
();
});
});
describe
(
'
conflicts editing
'
,
(
done
)
=>
{
describe
(
'
conflicts editing
'
,
()
=>
{
it
(
'
should show conflict message if note changes outside the component
'
,
()
=>
{
it
(
'
should show conflict message if note changes outside the component
'
,
(
done
)
=>
{
vm
.
isEditing
=
true
;
vm
.
noteBody
=
'
Foo
'
;
vm
.
noteBody
=
'
Foo
'
;
const
message
=
'
This comment has changed since you started editing, please review the updated comment to ensure information is not lost.
'
;
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
console
.
log
(
''
,
vm
.
$el
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-conflict-edit-warning
'
).
textContent
.
replace
(
/
\s
+/g
,
'
'
).
trim
(),
).
toEqual
(
message
);
done
();
done
();
});
});
});
});
...
@@ -44,56 +47,65 @@ fdescribe('issue_note_form component', () => {
...
@@ -44,56 +47,65 @@ fdescribe('issue_note_form component', () => {
describe
(
'
form
'
,
()
=>
{
describe
(
'
form
'
,
()
=>
{
it
(
'
should render text area with placeholder
'
,
()
=>
{
it
(
'
should render text area with placeholder
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
textarea
'
).
getAttribute
(
'
placeholder
'
),
).
toEqual
(
'
Write a comment or drag your files here...
'
);
});
});
it
(
'
should link to markdown docs
'
,
()
=>
{
it
(
'
should link to markdown docs
'
,
()
=>
{
const
{
markdownDocs
}
=
notesDataMock
;
});
expect
(
vm
.
$el
.
querySelector
(
`a[href="
${
markdownDocs
}
"]`
).
textContent
.
trim
()).
toEqual
(
'
Markdown
'
);
it
(
'
should link to quick actions docs
'
,
()
=>
{
});
it
(
'
should preview the content
'
,
()
=>
{
});
it
(
'
should allow quick actions
'
,
()
=>
{
});
});
describe
(
'
keyboard events
'
,
()
=>
{
describe
(
'
keyboard events
'
,
()
=>
{
describe
(
'
up
'
,
()
=>
{
describe
(
'
up
'
,
()
=>
{
it
(
'
should ender edit mode
'
,
()
=>
{
it
(
'
should ender edit mode
'
,
()
=>
{
spyOn
(
vm
,
'
editMyLastNote
'
).
and
.
callThrough
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
value
=
'
Foo
'
;
vm
.
$el
.
querySelector
(
'
textarea
'
).
dispatchEvent
(
keyboardDownEvent
(
38
,
true
));
expect
(
vm
.
editMyLastNote
).
toHaveBeenCalled
();
});
});
});
});
describe
(
'
enter
'
,
()
=>
{
describe
(
'
enter
'
,
()
=>
{
it
(
'
should submit note
'
,
()
=>
{
it
(
'
should submit note
'
,
()
=>
{
spyOn
(
vm
,
'
handleUpdate
'
).
and
.
callThrough
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
value
=
'
Foo
'
;
vm
.
$el
.
querySelector
(
'
textarea
'
).
dispatchEvent
(
keyboardDownEvent
(
13
,
true
));
});
expect
(
vm
.
handleUpdate
).
toHaveBeenCalled
();
});
describe
(
'
esc
'
,
()
=>
{
it
(
'
should show exit
'
,
()
=>
{
});
});
});
});
});
});
describe
(
'
actions
'
,
()
=>
{
describe
(
'
actions
'
,
()
=>
{
it
(
'
should be possible to cancel
'
,
()
=>
{
it
(
'
should be possible to cancel
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
cancelHandler
'
).
and
.
callThrough
();
vm
.
isEditing
=
true
;
});
Vue
.
nextTick
(()
=>
{
vm
.
$el
.
querySelector
(
'
.note-edit-cancel
'
).
click
();
it
(
'
should be possible to update the note
'
,
()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
cancelHandler
).
toHaveBeenCalled
();
done
();
});
});
});
});
it
(
'
should not be possible to save an empty note
'
,
()
=>
{
it
(
'
should be possible to update the note
'
,
(
done
)
=>
{
vm
.
isEditing
=
true
;
Vue
.
nextTick
(()
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
value
=
'
Foo
'
;
vm
.
$el
.
querySelector
(
'
.js-vue-issue-save
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
isSubmitting
).
toEqual
(
true
);
done
();
});
});
});
});
});
});
});
});
...
...
spec/javascripts/notes/stores/getters_spec.js
View file @
cbddad5a
import
{
getters
}
from
'
~/notes/stores/getters
'
;
import
*
as
getters
from
'
~/notes/stores/getters
'
;
import
{
notesDataMock
,
userDataMock
,
issueDataMock
,
individualNote
}
from
'
../mock_data
'
;
describe
(
'
Getters Notes Store
'
,
()
=>
{
describe
(
'
Getters Notes Store
'
,
()
=>
{
let
state
;
beforeEach
(()
=>
{
state
=
{
notes
:
[
individualNote
],
targetNoteHash
:
'
hash
'
,
lastFetchedAt
:
'
timestamp
'
,
notesData
:
notesDataMock
,
userData
:
userDataMock
,
issueData
:
issueDataMock
,
};
});
describe
(
'
notes
'
,
()
=>
{
describe
(
'
notes
'
,
()
=>
{
it
(
'
should return all notes in the store
'
,
()
=>
{
it
(
'
should return all notes in the store
'
,
()
=>
{
expect
(
getters
.
notes
(
state
)).
toEqual
([
individualNote
]);
});
});
});
});
describe
(
'
targetNoteHash
'
,
()
=>
{
describe
(
'
targetNoteHash
'
,
()
=>
{
it
(
'
should return `targetNoteHash`
'
,
()
=>
{
it
(
'
should return `targetNoteHash`
'
,
()
=>
{
expect
(
getters
.
targetNoteHash
(
state
)).
toEqual
(
'
hash
'
);
});
});
});
});
describe
(
'
getNotesData
'
,
()
=>
{
describe
(
'
getNotesData
'
,
()
=>
{
it
(
'
should return all data in `notesData`
'
,
()
=>
{
it
(
'
should return all data in `notesData`
'
,
()
=>
{
expect
(
getters
.
getNotesData
(
state
)).
toEqual
(
notesDataMock
);
});
});
describe
(
'
getNotesDataByProp
'
,
()
=>
{
it
(
'
should return the given prop
'
,
()
=>
{
});
});
});
});
describe
(
'
getIssueData
'
,
()
=>
{
describe
(
'
getIssueData
'
,
()
=>
{
it
(
'
should return all data in `issueData`
'
,
()
=>
{
it
(
'
should return all data in `issueData`
'
,
()
=>
{
expect
(
getters
.
getIssueData
(
state
)).
toEqual
(
issueDataMock
);
});
});
describe
(
'
getIssueDataByProp
'
,
()
=>
{
it
(
'
should return the given prop
'
,
()
=>
{
});
});
});
});
describe
(
'
getUserData
'
,
()
=>
{
describe
(
'
getUserData
'
,
()
=>
{
it
(
'
should return all data in `userData`
'
,
()
=>
{
it
(
'
should return all data in `userData`
'
,
()
=>
{
expect
(
getters
.
getUserData
(
state
)).
toEqual
(
userDataMock
);
});
});
describe
(
'
getUserDataByProp
'
,
()
=>
{
it
(
'
should return the given prop
'
,
()
=>
{
});
});
});
});
describe
(
'
notesById
'
,
()
=>
{
describe
(
'
notesById
'
,
()
=>
{
it
(
'
should return the note for the given id
'
,
()
=>
{
it
(
'
should return the note for the given id
'
,
()
=>
{
expect
(
getters
.
notesById
(
state
)).
toEqual
({
1390
:
individualNote
.
notes
[
0
]
});
});
});
});
});
describe
(
'
getCurrentUserLastNote
'
,
()
=>
{
describe
(
'
getCurrentUserLastNote
'
,
()
=>
{
it
(
'
should return the last note of the current user
'
,
()
=>
{
it
(
'
should return the last note of the current user
'
,
()
=>
{
expect
(
getters
.
getCurrentUserLastNote
(
state
)).
toEqual
(
individualNote
.
notes
[
0
]);
});
});
describe
(
'
getDiscussionLastNote
'
,
()
=>
{
it
(
'
should return the last discussion note of the current user
'
,
()
=>
{
});
});
});
});
});
});
spec/javascripts/notes/stores/mutation_spec.js
View file @
cbddad5a
import
{
mutations
}
from
'
~/notes/stores/mutations
'
;
import
mutations
from
'
~/notes/stores/mutations
'
;
import
{
note
,
discussionMock
,
notesDataMock
,
userDataMock
,
issueDataMock
,
individualNote
}
from
'
../mock_data
'
;
describe
(
'
Mutation Notes Store
'
,
()
=>
{
describe
(
'
Mutation Notes Store
'
,
()
=>
{
describe
(
'
ADD_NEW_NOTE
'
,
()
=>
{
describe
(
'
ADD_NEW_NOTE
'
,
()
=>
{
it
(
'
should add a new note to an array of notes
'
,
()
=>
{
it
(
'
should add a new note to an array of notes
'
,
()
=>
{
const
state
=
{
notes
:
[]
};
mutations
.
ADD_NEW_NOTE
(
state
,
note
);
expect
(
state
).
toEqual
({
notes
:
[{
expanded
:
true
,
id
:
note
.
discussion_id
,
individual_note
:
true
,
notes
:
[
note
],
reply_id
:
note
.
discussion_id
,
}],
});
});
});
});
});
describe
(
'
ADD_NEW_REPLY_TO_DISCUSSION
'
,
()
=>
{
describe
(
'
ADD_NEW_REPLY_TO_DISCUSSION
'
,
()
=>
{
it
(
'
should add a reply to a specific discussion
'
,
()
=>
{
it
(
'
should add a reply to a specific discussion
'
,
()
=>
{
const
state
=
{
notes
:
[
discussionMock
]
};
const
newReply
=
Object
.
assign
({},
note
,
{
discussion_id
:
discussionMock
.
id
});
mutations
.
ADD_NEW_REPLY_TO_DISCUSSION
(
state
,
newReply
);
expect
(
state
.
notes
[
0
].
notes
.
length
).
toEqual
(
4
);
});
});
});
});
describe
(
'
DELETE_NOTE
'
,
()
=>
{
describe
(
'
DELETE_NOTE
'
,
()
=>
{
it
(
'
should delete an indivudal note
'
,
()
=>
{
it
(
'
should delete a note
'
,
()
=>
{
const
state
=
{
notes
:
[
discussionMock
]
};
});
const
toDelete
=
discussionMock
.
notes
[
0
];
const
lengthBefore
=
discussionMock
.
notes
.
length
;
it
(
'
should delete a note from a discussion
'
,
()
=>
{
mutations
.
DELETE_NOTE
(
state
,
toDelete
);
expect
(
state
.
notes
[
0
].
notes
.
length
).
toEqual
(
lengthBefore
-
1
);
});
});
});
});
describe
(
'
REMOVE_PLACEHOLDER_NOTES
'
,
()
=>
{
describe
(
'
REMOVE_PLACEHOLDER_NOTES
'
,
()
=>
{
it
(
'
should remove all placeholder notes in indivudal notes and discussion
'
,
()
=>
{
it
(
'
should remove all placeholder notes in indivudal notes and discussion
'
,
()
=>
{
const
placeholderNote
=
Object
.
assign
({},
individualNote
,
{
isPlaceholderNote
:
true
});
const
state
=
{
notes
:
[
placeholderNote
]
};
mutations
.
REMOVE_PLACEHOLDER_NOTES
(
state
);
expect
(
state
.
notes
).
toEqual
([]);
});
});
});
});
describe
(
'
SET_NOTES_DATA
'
,
()
=>
{
describe
(
'
SET_NOTES_DATA
'
,
()
=>
{
it
(
'
should set an object with notesData
'
,
()
=>
{
it
(
'
should set an object with notesData
'
,
()
=>
{
const
state
=
{
notesData
:
{},
};
mutations
.
SET_NOTES_DATA
(
state
,
notesDataMock
);
expect
(
state
.
notesData
).
toEqual
(
notesDataMock
);
});
});
});
});
describe
(
'
SET_ISSUE_DATA
'
,
()
=>
{
describe
(
'
SET_ISSUE_DATA
'
,
()
=>
{
it
(
'
should set the issue data
'
,
()
=>
{
it
(
'
should set the issue data
'
,
()
=>
{
const
state
=
{
issueData
:
{},
};
mutations
.
SET_ISSUE_DATA
(
state
,
issueDataMock
);
expect
(
state
.
issueData
).
toEqual
(
issueDataMock
);
});
});
});
});
describe
(
'
SET_USER_DATA
'
,
()
=>
{
describe
(
'
SET_USER_DATA
'
,
()
=>
{
it
(
'
should set the user data
'
,
()
=>
{
it
(
'
should set the user data
'
,
()
=>
{
const
state
=
{
userData
:
{},
};
mutations
.
SET_USER_DATA
(
state
,
userDataMock
);
expect
(
state
.
userData
).
toEqual
(
userDataMock
);
});
});
});
});
describe
(
'
SET_INITAL_NOTES
'
,
()
=>
{
describe
(
'
SET_INIT
I
AL_NOTES
'
,
()
=>
{
it
(
'
should set the initial notes received
'
,
()
=>
{
it
(
'
should set the initial notes received
'
,
()
=>
{
const
state
=
{
notes
:
[],
};
mutations
.
SET_INITIAL_NOTES
(
state
,
[
note
]);
expect
(
state
.
notes
).
toEqual
([
note
]);
});
});
});
});
describe
(
'
SET_LAST_FETCHED_AT
'
,
()
=>
{
describe
(
'
SET_LAST_FETCHED_AT
'
,
()
=>
{
it
(
'
should set timestamp
'
,
()
=>
{});
it
(
'
should set timestamp
'
,
()
=>
{
const
state
=
{
lastFetchedAt
:
[],
};
mutations
.
SET_LAST_FETCHED_AT
(
state
,
'
timestamp
'
);
expect
(
state
.
lastFetchedAt
).
toEqual
(
'
timestamp
'
);
});
});
});
describe
(
'
SET_TARGET_NOTE_HASH
'
,
()
=>
{
describe
(
'
SET_TARGET_NOTE_HASH
'
,
()
=>
{
it
(
'
should set the note hash
'
,
()
=>
{});
it
(
'
should set the note hash
'
,
()
=>
{
const
state
=
{
targetNoteHash
:
[],
};
mutations
.
SET_TARGET_NOTE_HASH
(
state
,
'
hash
'
);
expect
(
state
.
targetNoteHash
).
toEqual
(
'
hash
'
);
});
});
});
describe
(
'
SHOW_PLACEHOLDER_NOTE
'
,
()
=>
{
describe
(
'
SHOW_PLACEHOLDER_NOTE
'
,
()
=>
{
it
(
'
should set a placeholder note
'
,
()
=>
{
it
(
'
should set a placeholder note
'
,
()
=>
{
const
state
=
{
notes
:
[],
};
mutations
.
SHOW_PLACEHOLDER_NOTE
(
state
,
note
);
expect
(
state
.
notes
[
0
].
isPlaceholderNote
).
toEqual
(
true
);
});
});
});
});
describe
(
'
TOGGLE_AWARD
'
,
()
=>
{
describe
(
'
TOGGLE_AWARD
'
,
()
=>
{
it
(
'
should add award if user has not reacted yet
'
,
()
=>
{
it
(
'
should add award if user has not reacted yet
'
,
()
=>
{
const
state
=
{
notes
:
[
note
],
userData
:
userDataMock
,
};
const
data
=
{
note
,
awardName
:
'
cartwheel
'
,
};
mutations
.
TOGGLE_AWARD
(
state
,
data
);
const
lastIndex
=
state
.
notes
[
0
].
award_emoji
.
length
-
1
;
expect
(
state
.
notes
[
0
].
award_emoji
[
lastIndex
]).
toEqual
({
name
:
'
cartwheel
'
,
user
:
{
id
:
userDataMock
.
id
,
name
:
userDataMock
.
name
,
username
:
userDataMock
.
username
},
});
});
});
it
(
'
should remove award if user already reacted
'
,
()
=>
{
it
(
'
should remove award if user already reacted
'
,
()
=>
{
const
state
=
{
notes
:
[
note
],
userData
:
{
id
:
1
,
name
:
'
Administrator
'
,
username
:
'
root
'
,
},
};
const
data
=
{
note
,
awardName
:
'
bath_tone3
'
,
};
mutations
.
TOGGLE_AWARD
(
state
,
data
);
expect
(
state
.
notes
[
0
].
award_emoji
.
length
).
toEqual
(
2
);
});
});
});
});
describe
(
'
TOGGLE_DISCUSSION
'
,
()
=>
{
describe
(
'
TOGGLE_DISCUSSION
'
,
()
=>
{
it
(
'
should open a closed discussion
'
,
()
=>
{
it
(
'
should open a closed discussion
'
,
()
=>
{
const
discussion
=
Object
.
assign
({},
discussionMock
,
{
expanded
:
false
});
const
state
=
{
notes
:
[
discussion
],
};
mutations
.
TOGGLE_DISCUSSION
(
state
,
{
discussionId
:
discussion
.
id
});
expect
(
state
.
notes
[
0
].
expanded
).
toEqual
(
true
);
});
});
it
(
'
should close a opened discussion
'
,
()
=>
{
it
(
'
should close a opened discussion
'
,
()
=>
{
const
state
=
{
notes
:
[
discussionMock
],
};
mutations
.
TOGGLE_DISCUSSION
(
state
,
{
discussionId
:
discussionMock
.
id
});
expect
(
state
.
notes
[
0
].
expanded
).
toEqual
(
false
);
});
});
});
});
describe
(
'
UPDATE_NOTE
'
,
()
=>
{
describe
(
'
UPDATE_NOTE
'
,
()
=>
{
it
(
'
should update an individual note
'
,
()
=>
{
it
(
'
should update a note
'
,
()
=>
{
const
state
=
{
notes
:
[
individualNote
],
};
});
const
updated
=
Object
.
assign
({},
individualNote
.
notes
[
0
],
{
note
:
'
Foo
'
});
it
(
'
should update a note in a discussion
'
,
()
=>
{
mutations
.
UPDATE_NOTE
(
state
,
updated
);
expect
(
state
.
notes
[
0
].
notes
[
0
].
note
).
toEqual
(
'
Foo
'
);
});
});
});
});
});
});
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