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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
57c32c7d
Commit
57c32c7d
authored
Jul 11, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds specs for getters in merge request vuex diff module
parent
135ead1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
95 deletions
+30
-95
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+0
-1
spec/javascripts/diffs/components/diff_file_header_spec.js
spec/javascripts/diffs/components/diff_file_header_spec.js
+1
-1
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+29
-93
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
57c32c7d
...
@@ -95,7 +95,6 @@ export const expandAllFiles = ({ commit }) => {
...
@@ -95,7 +95,6 @@ export const expandAllFiles = ({ commit }) => {
*/
*/
export
const
toggleFileDiscussions
=
({
getters
,
dispatch
},
diff
)
=>
{
export
const
toggleFileDiscussions
=
({
getters
,
dispatch
},
diff
)
=>
{
const
discussions
=
getters
.
getDiffFileDiscussions
(
diff
);
const
discussions
=
getters
.
getDiffFileDiscussions
(
diff
);
const
shouldCloseAll
=
getters
.
diffHasAllExpandedDiscussions
(
diff
);
const
shouldCloseAll
=
getters
.
diffHasAllExpandedDiscussions
(
diff
);
const
shouldExpandAll
=
getters
.
diffHasAllCollpasedDiscussions
(
diff
);
const
shouldExpandAll
=
getters
.
diffHasAllCollpasedDiscussions
(
diff
);
...
...
spec/javascripts/diffs/components/diff_file_header_spec.js
View file @
57c32c7d
...
@@ -4,7 +4,7 @@ import diffsModule from '~/diffs/store/modules';
...
@@ -4,7 +4,7 @@ import diffsModule from '~/diffs/store/modules';
import
notesModule
from
'
~/notes/stores/modules
'
;
import
notesModule
from
'
~/notes/stores/modules
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
DiffFileHeader
from
'
~/diffs/components/diff_file_header.vue
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
mountComponent
,
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mountComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
const
discussionFixture
=
'
merge_requests/diff_discussion.json
'
;
const
discussionFixture
=
'
merge_requests/diff_discussion.json
'
;
...
...
spec/javascripts/diffs/store/getters_spec.js
View file @
57c32c7d
...
@@ -5,9 +5,20 @@ import discussion from '../mock_data/diff_discussions';
...
@@ -5,9 +5,20 @@ import discussion from '../mock_data/diff_discussions';
describe
(
'
Diffs Module Getters
'
,
()
=>
{
describe
(
'
Diffs Module Getters
'
,
()
=>
{
let
localState
;
let
localState
;
let
discussionMock
;
let
discussionMock1
;
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
localState
=
state
();
localState
=
state
();
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
});
});
describe
(
'
isParallelView
'
,
()
=>
{
describe
(
'
isParallelView
'
,
()
=>
{
...
@@ -67,13 +78,6 @@ describe('Diffs Module Getters', () => {
...
@@ -67,13 +78,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasAllExpandedDiscussions
'
,
()
=>
{
describe
(
'
diffHasAllExpandedDiscussions
'
,
()
=>
{
it
(
'
returns true when all discussions are expanded
'
,
()
=>
{
it
(
'
returns true when all discussions are expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
expect
(
expect
(
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[
discussionMock
,
discussionMock
],
getDiffFileDiscussions
:
()
=>
[
discussionMock
,
discussionMock
],
...
@@ -82,10 +86,6 @@ describe('Diffs Module Getters', () => {
...
@@ -82,10 +86,6 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
expect
(
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getters
.
diffHasAllExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[],
getDiffFileDiscussions
:
()
=>
[],
...
@@ -94,15 +94,6 @@ describe('Diffs Module Getters', () => {
...
@@ -94,15 +94,6 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when one discussions is collapsed
'
,
()
=>
{
it
(
'
returns false when one discussions is collapsed
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
discussionMock1
.
expanded
=
false
;
expect
(
expect
(
...
@@ -115,11 +106,6 @@ describe('Diffs Module Getters', () => {
...
@@ -115,11 +106,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasAllCollpasedDiscussions
'
,
()
=>
{
describe
(
'
diffHasAllCollpasedDiscussions
'
,
()
=>
{
it
(
'
returns true when all discussions are collapsed
'
,
()
=>
{
it
(
'
returns true when all discussions are collapsed
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
expanded
=
false
;
discussionMock
.
expanded
=
false
;
...
@@ -131,10 +117,6 @@ describe('Diffs Module Getters', () => {
...
@@ -131,10 +117,6 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
expect
(
getters
.
diffHasAllCollpasedDiscussions
(
localState
,
{
getters
.
diffHasAllCollpasedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[],
getDiffFileDiscussions
:
()
=>
[],
...
@@ -143,14 +125,6 @@ describe('Diffs Module Getters', () => {
...
@@ -143,14 +125,6 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when one discussions is expanded
'
,
()
=>
{
it
(
'
returns false when one discussions is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
discussionMock1
.
expanded
=
false
;
expect
(
expect
(
...
@@ -163,14 +137,6 @@ describe('Diffs Module Getters', () => {
...
@@ -163,14 +137,6 @@ describe('Diffs Module Getters', () => {
describe
(
'
diffHasExpandedDiscussions
'
,
()
=>
{
describe
(
'
diffHasExpandedDiscussions
'
,
()
=>
{
it
(
'
returns true when one of the discussions is expanded
'
,
()
=>
{
it
(
'
returns true when one of the discussions is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
discussionMock1
.
expanded
=
false
;
expect
(
expect
(
...
@@ -181,10 +147,6 @@ describe('Diffs Module Getters', () => {
...
@@ -181,10 +147,6 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when there are no discussions
'
,
()
=>
{
it
(
'
returns false when there are no discussions
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
expect
(
expect
(
getters
.
diffHasExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[]
})(
getters
.
diffHasExpandedDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[]
})(
diffFileMock
,
diffFileMock
,
...
@@ -193,17 +155,7 @@ describe('Diffs Module Getters', () => {
...
@@ -193,17 +155,7 @@ describe('Diffs Module Getters', () => {
});
});
it
(
'
returns false when no discussion is expanded
'
,
()
=>
{
it
(
'
returns false when no discussion is expanded
'
,
()
=>
{
const
diffFileMock
=
{
fileHash
:
'
9732849daca6ae818696d9575f5d1207d1a7f8bb
'
,
};
const
discussionMock
=
Object
.
assign
({},
discussion
);
discussion
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock
.
expanded
=
false
;
discussionMock
.
expanded
=
false
;
const
discussionMock1
=
Object
.
assign
({},
discussion
);
discussionMock1
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
discussionMock1
.
expanded
=
false
;
discussionMock1
.
expanded
=
false
;
expect
(
expect
(
...
@@ -214,38 +166,22 @@ describe('Diffs Module Getters', () => {
...
@@ -214,38 +166,22 @@ describe('Diffs Module Getters', () => {
});
});
});
});
// describe('getDiffFileDiscussions', () => {
describe
(
'
getDiffFileDiscussions
'
,
()
=>
{
// it('returns an array with discussions when fileHash matches and the discussion belongs to a diff', () => {
it
(
'
returns an array with discussions when fileHash matches and the discussion belongs to a diff
'
,
()
=>
{
// const diffFileMock = {
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
// fileHash: '9732849daca6ae818696d9575f5d1207d1a7f8bb',
// };
expect
(
getters
.
getDiffFileDiscussions
(
localState
,
{},
{},
{
discussions
:
[
discussionMock
]
})(
// const discussionMock = Object.assign({}, discussion);
diffFileMock
,
// discussionMock.diff_file.file_hash = diffFileMock.fileHash;
).
length
,
).
toEqual
(
1
);
// expect(
});
// getters.getDiffFileDiscussions(
// localState,
it
(
'
returns an empty array when no discussions are found in the given diff
'
,
()
=>
{
// {},
expect
(
// {},
getters
.
getDiffFileDiscussions
(
localState
,
{},
{},
{
discussions
:
[]
})(
diffFileMock
)
// { discussions: [discussionMock] },
.
length
,
// )(diffFileMock).length,
).
toEqual
(
0
);
// ).toEqual(1);
});
// });
});
// it('returns an empty array when no discussions are found in the given diff', () => {
// const diffFileMock = {
// fileHash: '9732849daca6ae818696d9575f5d1207d1a7f8bb',
// };
// expect(
// getters.getDiffFileDiscussions(
// localState,
// {},
// {},
// { discussions: () => ([]) },
// )(diffFileMock).length,
// ).toEqual(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