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
ac271061
Commit
ac271061
authored
Mar 24, 2021
by
Jose Vargas
Committed by
Andrew Fontaine
Mar 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor commit_block specs
parent
d1bfaeb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
37 deletions
+25
-37
spec/frontend/jobs/components/commit_block_spec.js
spec/frontend/jobs/components/commit_block_spec.js
+25
-37
No files found.
spec/frontend/jobs/components/commit_block_spec.js
View file @
ac271061
...
...
@@ -6,77 +6,65 @@ import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
describe
(
'
Commit block
'
,
()
=>
{
let
wrapper
;
const
defaults
=
{
commit
:
{
short_id
:
'
1f0fb84f
'
,
id
:
'
1f0fb84fb6770d74d97eee58118fd3909cd4f48c
'
,
commit_path
:
'
commit/1f0fb84fb6770d74d97eee58118fd3909cd4f48c
'
,
title
:
'
Update README.md
'
,
},
mergeRequest
:
{
iid
:
'
!21244
'
,
path
:
'
merge_requests/21244
'
,
},
isLastBlock
:
true
,
const
commit
=
{
short_id
:
'
1f0fb84f
'
,
id
:
'
1f0fb84fb6770d74d97eee58118fd3909cd4f48c
'
,
commit_path
:
'
commit/1f0fb84fb6770d74d97eee58118fd3909cd4f48c
'
,
title
:
'
Update README.md
'
,
};
const
mergeRequest
=
{
iid
:
'
!21244
'
,
path
:
'
merge_requests/21244
'
,
};
const
findCommitSha
=
()
=>
wrapper
.
findByTestId
(
'
commit-sha
'
);
const
findLinkSha
=
()
=>
wrapper
.
findByTestId
(
'
link-commit
'
);
function
mountComponent
(
props
=
{})
{
const
mountComponent
=
(
props
)
=>
{
wrapper
=
extendedWrapper
(
shallowMount
(
CommitBlock
,
{
propsData
:
{
commit
,
...
props
,
},
}),
);
}
}
;
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
pipeline short sha
'
,
()
=>
{
describe
(
'
without merge request
'
,
()
=>
{
beforeEach
(()
=>
{
mountComponent
(
defaults
);
mountComponent
();
});
it
(
'
renders pipeline short sha link
'
,
()
=>
{
expect
(
findCommitSha
().
attributes
(
'
href
'
)).
toBe
(
defaults
.
commit
.
commit_path
);
expect
(
findCommitSha
().
text
()).
toBe
(
defaults
.
commit
.
short_id
);
expect
(
findCommitSha
().
attributes
(
'
href
'
)).
toBe
(
commit
.
commit_path
);
expect
(
findCommitSha
().
text
()).
toBe
(
commit
.
short_id
);
});
it
(
'
renders clipboard button
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
ClipboardButton
).
attributes
(
'
text
'
)).
toBe
(
defaults
.
commit
.
id
);
expect
(
wrapper
.
findComponent
(
ClipboardButton
).
attributes
(
'
text
'
)).
toBe
(
commit
.
id
);
});
});
describe
(
'
with merge request
'
,
()
=>
{
it
(
'
renders merge request link and reference
'
,
()
=>
{
mountComponent
(
defaults
);
expect
(
findLinkSha
().
attributes
(
'
href
'
)).
toBe
(
defaults
.
mergeRequest
.
path
);
expect
(
findLinkSha
().
text
()).
toBe
(
`!
${
defaults
.
mergeRequest
.
iid
}
`
);
it
(
'
renders git commit title
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
commit
.
title
);
});
});
describe
(
'
without merge request
'
,
()
=>
{
it
(
'
does not render merge request
'
,
()
=>
{
const
copyProps
=
{
...
defaults
};
delete
copyProps
.
mergeRequest
;
mountComponent
(
copyProps
);
expect
(
findLinkSha
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
git commit title
'
,
()
=>
{
it
(
'
renders
git commit titl
e
'
,
()
=>
{
mountComponent
(
defaults
);
describe
(
'
with merge request
'
,
()
=>
{
it
(
'
renders
merge request link and referenc
e
'
,
()
=>
{
mountComponent
(
{
mergeRequest
}
);
expect
(
wrapper
.
text
()).
toContain
(
defaults
.
commit
.
title
);
expect
(
findLinkSha
().
attributes
(
'
href
'
)).
toBe
(
mergeRequest
.
path
);
expect
(
findLinkSha
().
text
()).
toBe
(
`!
${
mergeRequest
.
iid
}
`
);
});
});
});
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