Commit 61ac2462 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'use-tooltip-component-in-mr-widget-author-time-component' into 'master'

Use Tooltip component in MrWidgetAuthorTime vue component

See merge request gitlab-org/gitlab-ce!19635
parents e6a5d3cc d5e91071
<script> <script>
import tooltip from '~/vue_shared/directives/tooltip';
import MrWidgetAuthor from './mr_widget_author.vue'; import MrWidgetAuthor from './mr_widget_author.vue';
export default { export default {
name: 'MRWidgetAuthorTime', name: 'MrWidgetAuthorTime',
components: { components: {
MrWidgetAuthor, MrWidgetAuthor,
}, },
directives: {
tooltip,
},
props: { props: {
actionText: { actionText: {
type: String, type: String,
...@@ -32,8 +36,7 @@ ...@@ -32,8 +36,7 @@
<mr-widget-author :author="author" /> <mr-widget-author :author="author" />
<time <time
:title="dateTitle" :title="dateTitle"
data-toggle="tooltip" v-tooltip
data-placement="top"
data-container="body" data-container="body"
> >
{{ dateReadable }} {{ dateReadable }}
......
<script> <script>
import mrWidgetAuthorTime from '../../components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '../../components/mr_widget_author_time.vue';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
export default { export default {
name: 'MRWidgetClosed', name: 'MRWidgetClosed',
components: { components: {
mrWidgetAuthorTime, MrWidgetAuthorTime,
statusIcon, statusIcon,
}, },
props: { props: {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import mrWidgetAuthorTime from '../../components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '../../components/mr_widget_author_time.vue';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
tooltip, tooltip,
}, },
components: { components: {
mrWidgetAuthorTime, MrWidgetAuthorTime,
loadingIcon, loadingIcon,
statusIcon, statusIcon,
ClipboardButton, ClipboardButton,
......
---
title: Use Tooltip component in MrWidgetAuthorTime vue comonent
merge_request: 19635
author: George Tsiolis
type: performance
import Vue from 'vue'; import Vue from 'vue';
import authorTimeComponent from '~/vue_merge_request_widget/components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '~/vue_merge_request_widget/components/mr_widget_author_time.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('MRWidgetAuthorTime', () => { describe('MrWidgetAuthorTime', () => {
let vm; let vm;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(authorTimeComponent); const Component = Vue.extend(MrWidgetAuthorTime);
vm = mountComponent(Component, { vm = mountComponent(Component, {
actionText: 'Merged by', actionText: 'Merged by',
...@@ -34,7 +34,7 @@ describe('MRWidgetAuthorTime', () => { ...@@ -34,7 +34,7 @@ describe('MRWidgetAuthorTime', () => {
}); });
it('renders provided time', () => { it('renders provided time', () => {
expect(vm.$el.querySelector('time').getAttribute('title')).toEqual('2017-03-23T23:02:00.807Z'); expect(vm.$el.querySelector('time').getAttribute('data-original-title')).toEqual('2017-03-23T23:02:00.807Z');
expect(vm.$el.querySelector('time').textContent.trim()).toEqual('12 hours ago'); expect(vm.$el.querySelector('time').textContent.trim()).toEqual('12 hours ago');
}); });
}); });
...@@ -186,7 +186,7 @@ describe('MRWidgetMerged', () => { ...@@ -186,7 +186,7 @@ describe('MRWidgetMerged', () => {
it('should use mergedEvent mergedAt as tooltip title', () => { it('should use mergedEvent mergedAt as tooltip title', () => {
expect( expect(
vm.$el.querySelector('time').getAttribute('title'), vm.$el.querySelector('time').getAttribute('data-original-title'),
).toBe('Jan 24, 2018 1:02pm GMT+0000'); ).toBe('Jan 24, 2018 1:02pm GMT+0000');
}); });
}); });
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