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
Jérome Perrin
gitlab-ce
Commits
d9b7c33f
Commit
d9b7c33f
authored
Mar 26, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated MR Widget Header Test
parent
ae3abc38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
106 deletions
+138
-106
spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js
...scripts/vue_mr_widget/components/mr_widget_header_spec.js
+138
-106
No files found.
spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js
View file @
d9b7c33f
...
...
@@ -17,46 +17,58 @@ describe('MRWidgetHeader', () => {
describe
(
'
computed
'
,
()
=>
{
describe
(
'
shouldShowCommitsBehindText
'
,
()
=>
{
it
(
'
return true when there are divergedCommitsCount
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
statusPath
:
'
abc
'
,
},
});
expect
(
vm
.
shouldShowCommitsBehindText
).
toEqual
(
true
);
});
it
(
'
returns false where there are no divergedComits count
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
0
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
0
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
statusPath
:
'
abc
'
,
},
});
expect
(
vm
.
shouldShowCommitsBehindText
).
toEqual
(
false
);
});
});
describe
(
'
commitsText
'
,
()
=>
{
it
(
'
returns singular when there is one commit
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
1
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
1
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
statusPath
:
'
abc
'
,
},
});
expect
(
vm
.
commitsText
).
toEqual
(
'
1 commit behind
'
);
});
it
(
'
returns plural when there is more than one commit
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
2
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
2
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">Link</a>
'
,
targetBranch
:
'
master
'
,
statusPath
:
'
abc
'
,
},
});
expect
(
vm
.
commitsText
).
toEqual
(
'
2 commits behind
'
);
});
...
...
@@ -66,24 +78,27 @@ describe('MRWidgetHeader', () => {
describe
(
'
template
'
,
()
=>
{
describe
(
'
common elements
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
statusPath
:
'
abc
'
,
},
});
});
it
(
'
renders source branch link
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-source-branch
'
).
innerHTML
,
)
.
toEqual
(
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
)
;
expect
(
vm
.
$el
.
querySelector
(
'
.js-source-branch
'
).
innerHTML
).
toEqual
(
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
);
});
it
(
'
renders clipboard button
'
,
()
=>
{
...
...
@@ -101,18 +116,21 @@ describe('MRWidgetHeader', () => {
});
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
statusPath
:
'
abc
'
,
},
});
});
it
(
'
renders checkout branch button with modal trigger
'
,
()
=>
{
...
...
@@ -123,39 +141,49 @@ describe('MRWidgetHeader', () => {
expect
(
button
.
getAttribute
(
'
data-toggle
'
)).
toEqual
(
'
modal
'
);
});
it
(
'
renders web ide button
'
,
()
=>
{
const
button
=
vm
.
$el
.
querySelector
(
'
.js-web-ide
'
);
expect
(
button
.
textContent
.
trim
()).
toEqual
(
'
Open in Web IDE
'
);
expect
(
button
.
getAttribute
(
'
href
'
)).
toEqual
(
'
undefined/-/ide/projectabc
'
);
});
it
(
'
renders download dropdown with links
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
).
textContent
.
trim
()
,
)
.
toEqual
(
'
Email patches
'
)
;
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
).
textContent
.
trim
()).
toEqual
(
'
Email patches
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
).
getAttribute
(
'
href
'
)
,
)
.
toEqual
(
'
/mr/email-patches
'
)
;
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
).
getAttribute
(
'
href
'
)).
toEqual
(
'
/mr/email-patches
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
).
textContent
.
trim
()
,
)
.
toEqual
(
'
Plain diff
'
)
;
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
).
textContent
.
trim
()).
toEqual
(
'
Plain diff
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
).
getAttribute
(
'
href
'
)
,
)
.
toEqual
(
'
/mr/plainDiffPath
'
)
;
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
).
getAttribute
(
'
href
'
)).
toEqual
(
'
/mr/plainDiffPath
'
,
);
});
});
describe
(
'
with a closed merge request
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
false
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
false
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
statusPath
:
'
abc
'
,
},
});
});
it
(
'
does not render checkout branch button with modal trigger
'
,
()
=>
{
...
...
@@ -165,30 +193,29 @@ describe('MRWidgetHeader', () => {
});
it
(
'
does not render download dropdown with links
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
),
).
toEqual
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-email-patches
'
)).
toEqual
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
),
).
toEqual
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-download-plain-diff
'
)).
toEqual
(
null
);
});
});
describe
(
'
without diverged commits
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
0
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
0
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
statusPath
:
'
abc
'
,
},
});
});
it
(
'
does not render diverged commits info
'
,
()
=>
{
...
...
@@ -198,22 +225,27 @@ describe('MRWidgetHeader', () => {
describe
(
'
with diverged commits
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
}
});
vm
=
mountComponent
(
Component
,
{
mr
:
{
divergedCommitsCount
:
12
,
sourceBranch
:
'
mr-widget-refactor
'
,
sourceBranchLink
:
'
<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>
'
,
sourceBranchRemoved
:
false
,
targetBranchPath
:
'
foo/bar/commits-path
'
,
targetBranchTreePath
:
'
foo/bar/tree/path
'
,
targetBranch
:
'
master
'
,
isOpen
:
true
,
emailPatchesPath
:
'
/mr/email-patches
'
,
plainDiffPath
:
'
/mr/plainDiffPath
'
,
statusPath
:
'
abc
'
,
},
});
});
it
(
'
renders diverged commits info
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.diverged-commits-count
'
).
textContent
.
trim
()).
toEqual
(
'
(12 commits behind)
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.diverged-commits-count
'
).
textContent
.
trim
()).
toEqual
(
'
(12 commits behind)
'
,
);
});
});
});
...
...
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