Commit 9f800079 authored by Fatih Acet's avatar Fatih Acet

MRWidget: Fix specs and address WIP comments.

parent a2dbb693
...@@ -5,20 +5,17 @@ export default { ...@@ -5,20 +5,17 @@ export default {
props: { props: {
mr: { mr: {
type: Object, type: Object,
default: false, required: true,
}, },
}, },
data() { data() {
return { return { emptyStateSVG };
canCreateNewFile: true,
emptyStateSVG,
};
}, },
template: ` template: `
<div class="mr-widget-body empty-state"> <div class="mr-widget-body empty-state">
<div class="row"> <div class="row">
<div class="artwork col-sm-5 col-sm-push-7 col-xs-12 text-center"> <div class="artwork col-sm-5 col-sm-push-7 col-xs-12 text-center">
<span v-html="emptyStateSVG" /> <span v-html="emptyStateSVG"></span>
</div> </div>
<div class="text col-sm-7 col-sm-pull-5 col-xs-12"> <div class="text col-sm-7 col-sm-pull-5 col-xs-12">
<span> <span>
...@@ -33,7 +30,7 @@ export default { ...@@ -33,7 +30,7 @@ export default {
Please push new commits or use a different branch. Please push new commits or use a different branch.
</p> </p>
<a <a
v-if="canCreateNewFile" v-if="mr.newBlobPath"
:href="mr.newBlobPath" :href="mr.newBlobPath"
role="button" role="button"
class="btn btn-inverted btn-save"> class="btn btn-inverted btn-save">
......
...@@ -354,10 +354,12 @@ ...@@ -354,10 +354,12 @@
.artwork { .artwork {
margin-bottom: $gl-padding; margin-bottom: $gl-padding;
} }
.text { .text {
span { span {
font-weight: bold; font-weight: bold;
} }
p { p {
margin-top: $gl-padding; margin-top: $gl-padding;
} }
......
...@@ -4,14 +4,26 @@ import nothingToMergeComponent from '~/vue_merge_request_widget/components/state ...@@ -4,14 +4,26 @@ import nothingToMergeComponent from '~/vue_merge_request_widget/components/state
describe('MRWidgetNothingToMerge', () => { describe('MRWidgetNothingToMerge', () => {
describe('template', () => { describe('template', () => {
const Component = Vue.extend(nothingToMergeComponent); const Component = Vue.extend(nothingToMergeComponent);
const newBlobPath = '/foo';
const vm = new Component({ const vm = new Component({
el: document.createElement('div'), el: document.createElement('div'),
propsData: {
mr: { newBlobPath },
},
}); });
it('should have correct elements', () => { it('should have correct elements', () => {
expect(vm.$el.classList.contains('mr-widget-body')).toBeTruthy(); expect(vm.$el.classList.contains('mr-widget-body')).toBeTruthy();
expect(vm.$el.querySelector('button').getAttribute('disabled')).toBeTruthy(); expect(vm.$el.querySelector('a').href).toContain(newBlobPath);
expect(vm.$el.innerText).toContain('There is nothing to merge from source branch into target branch.'); expect(vm.$el.innerText).toContain("Currently there are no changes in this merge request's source branch");
expect(vm.$el.innerText).toContain('Please push new commits or use a different branch.'); expect(vm.$el.innerText).toContain('Please push new commits or use a different branch.');
}); });
it('should not show new blob link if there is no link available', () => {
vm.mr.newBlobPath = null;
Vue.nextTick(() => {
expect(vm.$el.querySelector('a')).toEqual(null);
});
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment