Merge branch 'develop' into feat/media-modal

This commit is contained in:
shpuld 2019-01-30 20:49:24 +02:00
commit c7cffbb6c7
32 changed files with 349 additions and 50 deletions

View file

@ -240,6 +240,15 @@ describe('The Statuses module', () => {
expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true)
})
it('keeps userId when clearing user timeline', () => {
const state = cloneDeep(defaultState)
state.timelines.user.userId = 123
mutations.clearTimeline(state, { timeline: 'user' })
expect(state.timelines.user.userId).to.eql(123)
})
describe('notifications', () => {
it('removes a notification when the notice gets removed', () => {
const user = { id: '1' }

View file

@ -45,6 +45,17 @@ describe('The users module', () => {
const expected = { screen_name: 'Guy', id: '1' }
expect(getters.userByName(state)(name)).to.eql(expected)
})
it('returns user with matching screen_name with different case', () => {
const state = {
users: [
{ screen_name: 'guy', id: '1' }
]
}
const name = 'Guy'
const expected = { screen_name: 'guy', id: '1' }
expect(getters.userByName(state)(name)).to.eql(expected)
})
})
describe('getUserById', () => {

View file

@ -0,0 +1,63 @@
import * as MentionMatcher from 'src/services/mention_matcher/mention_matcher.js'
const localAttn = () => ({
id: 123,
is_local: true,
name: 'Guy',
screen_name: 'person',
statusnet_profile_url: 'https://instance.com/users/person'
})
const externalAttn = () => ({
id: 123,
is_local: false,
name: 'Guy',
screen_name: 'person@instance.com',
statusnet_profile_url: 'https://instance.com/users/person'
})
describe('MentionMatcher', () => {
describe.only('mentionMatchesUrl', () => {
it('should match local mention', () => {
const attention = localAttn()
const url = 'https://instance.com/users/person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
})
it('should not match a local mention with same name but different instance', () => {
const attention = localAttn()
const url = 'https://website.com/users/person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
})
it('should match external pleroma mention', () => {
const attention = externalAttn()
const url = 'https://instance.com/users/person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
})
it('should not match external pleroma mention with same name but different instance', () => {
const attention = externalAttn()
const url = 'https://website.com/users/person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
})
it('should match external mastodon mention', () => {
const attention = externalAttn()
const url = 'https://instance.com/@person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(true)
})
it('should not match external mastodon mention with same name but different instance', () => {
const attention = externalAttn()
const url = 'https://website.com/@person'
expect(MentionMatcher.mentionMatchesUrl(attention, url)).to.eql(false)
})
})
})