From d513fc2ca5e604faeba63ba0e14286cfbf8b1e8b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 24 Oct 2022 16:31:11 +0200 Subject: [PATCH] add tests for the links in messages --- .../ContributionMessagesListItem.spec.js | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js index 7504854d0..2dc9fb3ce 100644 --- a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js +++ b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js @@ -175,4 +175,68 @@ describe('ContributionMessagesListItem', () => { }) }) }) + + describe('links in contribtion message', () => { + const propsData = { + message: { + id: 111, + message: 'Lorem ipsum?', + createdAt: '2022-08-29T12:23:27.000Z', + updatedAt: null, + type: 'DIALOG', + userFirstName: 'Peter', + userLastName: 'Lustig', + userId: 107, + __typename: 'ContributionMessage', + }, + } + + const ModeratorItemWrapper = () => { + return mount(ContributionMessagesListItem, { + localVue, + mocks, + propsData, + }) + } + + let messageField + + describe('message of only one link', () => { + beforeEach(() => { + propsData.message.message = 'https://gradido.net/de/' + wrapper = ModeratorItemWrapper() + messageField = wrapper.find('div.is-not-moderator.text-right > div:nth-child(4)') + }) + + it('contains the link as text', () => { + expect(messageField.text()).toBe('https://gradido.net/de/') + }) + + it('contains a link to the given address', () => { + expect(messageField.find('a').attributes('href')).toBe('https://gradido.net/de/') + }) + }) + + describe('message with text and two links', () => { + beforeEach(() => { + propsData.message.message = `Here you find all you need to know about Gradido: https://gradido.net/de/ +and here is the link to the repository: https://github.com/gradido/gradido` + wrapper = ModeratorItemWrapper() + messageField = wrapper.find('div.is-not-moderator.text-right > div:nth-child(4)') + }) + + it('contains the whole text', () => { + expect(messageField.text()) + .toBe(`Here you find all you need to know about Gradido: https://gradido.net/de/ +and here is the link to the repository: https://github.com/gradido/gradido`) + }) + + it('contains the two links', () => { + expect(messageField.findAll('a').at(0).attributes('href')).toBe('https://gradido.net/de/') + expect(messageField.findAll('a').at(1).attributes('href')).toBe( + 'https://github.com/gradido/gradido', + ) + }) + }) + }) })