chore: Replace messageMixing with useMessage composable [CW-3475] (#9942)
# Pull Request Template ## Description Replaces the messageMixin with the new useMessage composable Fixes https://linear.app/chatwoot/issue/CW-3475/rewrite-messagemixin-mixin-to-a-composable ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
export default {
|
||||
computed: {
|
||||
messageContentAttributes() {
|
||||
const { content_attributes: attribute = {} } = this.message;
|
||||
return attribute;
|
||||
},
|
||||
hasAttachments() {
|
||||
return !!(
|
||||
this.message.attachments && this.message.attachments.length > 0
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import messageMixin from '../messageMixin';
|
||||
import messages from './messageFixture';
|
||||
|
||||
describe('messageMixin', () => {
|
||||
let Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [messageMixin],
|
||||
};
|
||||
|
||||
it('deleted messages', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
data() {
|
||||
return {
|
||||
message: messages.deletedMessage,
|
||||
};
|
||||
},
|
||||
});
|
||||
expect(wrapper.vm.messageContentAttributes).toEqual({
|
||||
deleted: true,
|
||||
});
|
||||
expect(wrapper.vm.hasAttachments).toBe(false);
|
||||
});
|
||||
it('non-deleted messages', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
data() {
|
||||
return {
|
||||
message: messages.nonDeletedMessage,
|
||||
};
|
||||
},
|
||||
});
|
||||
expect(wrapper.vm.deletedMessage).toBe(undefined);
|
||||
expect(wrapper.vm.messageContentAttributes).toEqual({});
|
||||
expect(wrapper.vm.hasAttachments).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user