diff --git a/backend/src/middleware/handleHtmlContent/handleContentData.js b/backend/src/middleware/handleHtmlContent/handleContentData.js index 8efdef90f..6519ddae7 100644 --- a/backend/src/middleware/handleHtmlContent/handleContentData.js +++ b/backend/src/middleware/handleHtmlContent/handleContentData.js @@ -66,4 +66,4 @@ export default { CreatePost: handleContentData, UpdatePost: handleContentData, }, -} \ No newline at end of file +} diff --git a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js index 12b34dff0..5ac0f3eda 100644 --- a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js +++ b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js @@ -1,11 +1,6 @@ -import { - GraphQLClient -} from 'graphql-request' +import { GraphQLClient } from 'graphql-request' import gql from 'graphql-tag' -import { - host, - login -} from '../../jest/helpers' +import { host, login } from '../../jest/helpers' import Factory from '../../seed/factories' const factory = Factory() @@ -26,7 +21,7 @@ afterEach(async () => { }) describe('currentUser { notifications }', () => { - const query = gql ` + const query = gql` query($read: Boolean) { currentUser { notifications(read: $read, orderBy: createdAt_desc) { @@ -73,7 +68,7 @@ describe('currentUser { notifications }', () => { 'Hey @al-capone how do you do?' beforeEach(async () => { - const createPostMutation = gql ` + const createPostMutation = gql` mutation($title: String!, $content: String!) { CreatePost(title: $title, content: $content) { id @@ -85,9 +80,7 @@ describe('currentUser { notifications }', () => { authorClient = new GraphQLClient(host, { headers: authorHeaders, }) - const { - CreatePost - } = await authorClient.request(createPostMutation, { + const { CreatePost } = await authorClient.request(createPostMutation, { title, content, }) @@ -99,12 +92,14 @@ describe('currentUser { notifications }', () => { 'Hey @al-capone how do you do?' const expected = { currentUser: { - notifications: [{ - read: false, - post: { - content: expectedContent, + notifications: [ + { + read: false, + post: { + content: expectedContent, + }, }, - }, ], + ], }, } await expect( @@ -122,7 +117,7 @@ describe('currentUser { notifications }', () => { // during development and thought: A feature not a bug! This way we // can encode a re-mentioning of users when you edit your post or // comment. - const createPostMutation = gql ` + const createPostMutation = gql` mutation($id: ID!, $content: String!) { UpdatePost(id: $id, content: $content) { title @@ -144,7 +139,8 @@ describe('currentUser { notifications }', () => { 'Hey @al-capone how do you do? One more mention to @al-capone' const expected = { currentUser: { - notifications: [{ + notifications: [ + { read: false, post: { content: expectedContent, @@ -176,7 +172,7 @@ describe('Hashtags', () => { const postTitle = 'Two Hashtags' const postContent = '

Hey Dude, #Democracy should work equal for everybody!? That seems to be the only way to have equal #Liberty for everyone.

' - const postWithHastagsQuery = gql ` + const postWithHastagsQuery = gql` query($id: ID) { Post(id: $id) { tags { @@ -188,7 +184,7 @@ describe('Hashtags', () => { const postWithHastagsVariables = { id: postId, } - const createPostMutation = gql ` + const createPostMutation = gql` mutation($postId: ID, $postTitle: String!, $postContent: String!) { CreatePost(id: $postId, title: $postTitle, content: $postContent) { id @@ -220,7 +216,8 @@ describe('Hashtags', () => { }) it('both Hashtags are created', async () => { - const expected = [{ + const expected = [ + { name: 'Democracy', }, { @@ -230,9 +227,11 @@ describe('Hashtags', () => { await expect( client.request(postWithHastagsQuery, postWithHastagsVariables), ).resolves.toEqual({ - Post: [{ - tags: expect.arrayContaining(expected), - }, ], + Post: [ + { + tags: expect.arrayContaining(expected), + }, + ], }) }) @@ -240,7 +239,7 @@ describe('Hashtags', () => { // The already existing Hashtag has no class at this point. const updatedPostContent = '

Hey Dude, #Elections should work equal for everybody!? That seems to be the only way to have equal #Liberty for everyone.

' - const updatePostMutation = gql ` + const updatePostMutation = gql` mutation($postId: ID!, $postTitle: String, $updatedPostContent: String) { UpdatePost(id: $postId, title: $postTitle, content: $updatedPostContent) { id @@ -257,7 +256,8 @@ describe('Hashtags', () => { updatedPostContent, }) - const expected = [{ + const expected = [ + { name: 'Elections', }, { @@ -267,12 +267,14 @@ describe('Hashtags', () => { await expect( client.request(postWithHastagsQuery, postWithHastagsVariables), ).resolves.toEqual({ - Post: [{ - tags: expect.arrayContaining(expected), - }, ], + Post: [ + { + tags: expect.arrayContaining(expected), + }, + ], }) }) }) }) }) -}) \ No newline at end of file +}) diff --git a/backend/src/middleware/handleHtmlContent/hashtags/extractHashtags.js b/backend/src/middleware/handleHtmlContent/hashtags/extractHashtags.js index a7c75d2f8..5e77e6e3a 100644 --- a/backend/src/middleware/handleHtmlContent/hashtags/extractHashtags.js +++ b/backend/src/middleware/handleHtmlContent/hashtags/extractHashtags.js @@ -1,7 +1,7 @@ import cheerio from 'cheerio' const ID_REGEX = /\/search\/hashtag\/([\w\-.!~*'"(),]+)/g -export default function (content) { +export default function(content) { if (!content) return [] const $ = cheerio.load(content) // We can not search for class '.hashtag', because the classes are removed at the 'xss' middleware. @@ -19,4 +19,4 @@ export default function (content) { } }) return hashtags -} \ No newline at end of file +} diff --git a/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.js b/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.js index ccc9944b2..c2fcf169c 100644 --- a/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.js +++ b/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.js @@ -1,7 +1,7 @@ import cheerio from 'cheerio' const ID_REGEX = /\/profile\/([\w\-.!~*'"(),]+)/g -export default function (content) { +export default function(content) { if (!content) return [] const $ = cheerio.load(content) const urls = $('.mention') @@ -17,4 +17,4 @@ export default function (content) { } }) return ids -} \ No newline at end of file +} diff --git a/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.spec.js b/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.spec.js index fd60f96ab..f39fbc859 100644 --- a/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.spec.js +++ b/backend/src/middleware/handleHtmlContent/notifications/extractMentionedUsers.spec.js @@ -56,4 +56,4 @@ describe('extractMentionedUsers', () => { }) }) }) -}) \ No newline at end of file +})