test: reorderedTimeline filter scenarios
This commit is contained in:
parent
3f2227ef4c
commit
5de275b505
@ -5,7 +5,21 @@ import type { mastodon } from 'masto'
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { reorderedTimeline } from '~/composables/timeline'
|
import { reorderedTimeline } from '~/composables/timeline'
|
||||||
|
|
||||||
function status(id: string): mastodon.v1.Status {
|
function status(id: string, filtered?: mastodon.v1.FilterContext): mastodon.v1.Status {
|
||||||
|
if (filtered) {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
filtered: [
|
||||||
|
{
|
||||||
|
filter: {
|
||||||
|
filterAction: 'hide',
|
||||||
|
context: [filtered],
|
||||||
|
},
|
||||||
|
} as mastodon.v1.FilterResult,
|
||||||
|
],
|
||||||
|
} as mastodon.v1.Status
|
||||||
|
}
|
||||||
|
|
||||||
return { id } as mastodon.v1.Status
|
return { id } as mastodon.v1.Status
|
||||||
}
|
}
|
||||||
function reply(id: string, s: mastodon.v1.Status) {
|
function reply(id: string, s: mastodon.v1.Status) {
|
||||||
@ -30,6 +44,11 @@ const r_b1 = reblog('r_b1', p_b1)
|
|||||||
const r_a2 = reblog('r_a2', p_a2)
|
const r_a2 = reblog('r_a2', p_a2)
|
||||||
const r_b2 = reblog('r_b2', p_b2)
|
const r_b2 = reblog('r_b2', p_b2)
|
||||||
|
|
||||||
|
const f = status('f', 'public')
|
||||||
|
const r_f = reply('r_f', f)
|
||||||
|
const rb_f = reblog('rb_f', f)
|
||||||
|
const n_f = status('f', 'notifications')
|
||||||
|
|
||||||
describe('timeline reordering', () => {
|
describe('timeline reordering', () => {
|
||||||
it('reorder basic', () => {
|
it('reorder basic', () => {
|
||||||
expect(reorderedTimeline([r_a2, r_a1])).toEqual([r_a1, r_a2])
|
expect(reorderedTimeline([r_a2, r_a1])).toEqual([r_a1, r_a2])
|
||||||
@ -52,4 +71,21 @@ describe('timeline reordering', () => {
|
|||||||
|
|
||||||
expect(reorderedTimeline([p_a3, r_a1, r_a2, r_b2, p_b3, r_b1])).toEqual([r_a1, r_a2, p_a3, r_b1, r_b2, p_b3])
|
expect(reorderedTimeline([p_a3, r_a1, r_a2, r_b2, p_b3, r_b1])).toEqual([r_a1, r_a2, p_a3, r_b1, r_b2, p_b3])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('reorder with filtered item', () => {
|
||||||
|
// should not show filtered status with 'hide' filterAction
|
||||||
|
expect(reorderedTimeline([p_a3, f, r_a1, r_a2, r_b2, p_b3, r_b1])).toEqual([r_a1, r_a2, p_a3, r_b1, r_b2, p_b3])
|
||||||
|
|
||||||
|
// should not filter status with 'hide' filterAction but does not matches context
|
||||||
|
expect(reorderedTimeline([p_a3, n_f, r_a1, r_a2, r_b2, p_b3, r_b1], 'public')).toEqual([r_a1, r_a2, p_a3, n_f, r_b1, r_b2, p_b3])
|
||||||
|
|
||||||
|
// should filter status with 'hide' filterAction and matches context
|
||||||
|
expect(reorderedTimeline([p_a3, n_f, r_a1, r_a2, r_b2, p_b3, r_b1], 'notifications')).toEqual([r_a1, r_a2, p_a3, r_b1, r_b2, p_b3])
|
||||||
|
|
||||||
|
// should show reply to a filtered status
|
||||||
|
expect(reorderedTimeline([p_a3, f, r_a1, r_f, r_a2, r_b2, p_b3, r_b1])).toEqual([r_a1, r_a2, p_a3, r_f, r_b1, r_b2, p_b3])
|
||||||
|
|
||||||
|
// should not show reblogged status that is filtered with 'hide' filterAction
|
||||||
|
expect(reorderedTimeline([p_a3, f, r_a1, rb_f, r_a2, r_b2, p_b3, r_b1])).toEqual([r_a1, r_a2, p_a3, r_b1, r_b2, p_b3])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user