post-merge lint

This commit is contained in:
Henry Jameson 2026-09-04 01:06:54 +03:00
commit 93cabbf945
3 changed files with 1664 additions and 4853 deletions

View file

@ -476,100 +476,105 @@ describe('Statuses store', () => {
]) ])
.flat() .flat()
it.each( it.each(optimismInteractions)(
optimismInteractions, '%s - optimism call',
)('%s - optimism call', async (method, property, count) => { async (method, property, count) => {
// Prepare our status // Prepare our status
const status = mockStatus() const status = mockStatus()
const negate = method.startsWith('un') const negate = method.startsWith('un')
const oldCount = 9 const oldCount = 9
const newCount = negate ? 8 : 10 const newCount = negate ? 8 : 10
status[property] = negate status[property] = negate
if (count) { if (count) {
status[count] = oldCount status[count] = oldCount
} }
if (method === 'unbookmark') { if (method === 'unbookmark') {
status.bookmark_folder_id = 'argument' status.bookmark_folder_id = 'argument'
} }
// Insert it // Insert it
const store = useStatusesStore() const store = useStatusesStore()
store.addNewStatuses({ store.addNewStatuses({
statuses: [status], statuses: [status],
timestamp: 1, timestamp: 1,
}) })
const mockFetch = vi.fn() const mockFetch = vi.fn()
mockFetch.mockResolvedValueOnce( mockFetch.mockResolvedValueOnce(
new Response(JSON.stringify(mockMastoAPIStatus({ text: 'Updated' })), { new Response(
headers: { 'Content-Type': 'application/json' }, JSON.stringify(mockMastoAPIStatus({ text: 'Updated' })),
}), {
) headers: { 'Content-Type': 'application/json' },
},
expect(store.allStatuses.get('1')).to.have.property(property, negate) ),
if (count) {
expect(store.allStatuses.get('1')).to.have.property(count, oldCount)
}
vi.stubGlobal('fetch', mockFetch)
store[method]('1', 'argument')
expect(store.allStatuses.get('1')).to.have.property(property, !negate)
if (count) {
expect(store.allStatuses.get('1')).to.have.property(count, newCount)
}
if (property === 'bookmarked') {
expect(store.allStatuses.get('1')).to.have.property(
'bookmark_folder_id',
'argument',
) )
}
})
it.each( expect(store.allStatuses.get('1')).to.have.property(property, negate)
optimismInteractions, if (count) {
)('%s - optimism fail', async (method, property, count) => { expect(store.allStatuses.get('1')).to.have.property(count, oldCount)
// Prepare our status }
const status = mockStatus() vi.stubGlobal('fetch', mockFetch)
const negate = method.startsWith('un')
const oldCount = 9
status[property] = negate
if (count) {
status[count] = oldCount
}
if (method === 'unbookmark') {
status.bookmark_folder_id = 'argument'
}
// Insert it store[method]('1', 'argument')
const store = useStatusesStore() expect(store.allStatuses.get('1')).to.have.property(property, !negate)
store.addNewStatuses({ if (count) {
statuses: [status], expect(store.allStatuses.get('1')).to.have.property(count, newCount)
timestamp: 1, }
}) if (property === 'bookmarked') {
expect(store.allStatuses.get('1')).to.have.property(
'bookmark_folder_id',
'argument',
)
}
},
)
const mockFetch = vi.fn() it.each(optimismInteractions)(
mockFetch.mockRejectedValueOnce(new Error('Failure!')) '%s - optimism fail',
async (method, property, count) => {
// Prepare our status
const status = mockStatus()
const negate = method.startsWith('un')
const oldCount = 9
status[property] = negate
if (count) {
status[count] = oldCount
}
if (method === 'unbookmark') {
status.bookmark_folder_id = 'argument'
}
expect(store.allStatuses.get('1')).to.have.property(property, negate) // Insert it
if (count) { const store = useStatusesStore()
expect(store.allStatuses.get('1')).to.have.property(count, oldCount) store.addNewStatuses({
} statuses: [status],
vi.stubGlobal('fetch', mockFetch) timestamp: 1,
})
await store[method]('1', 'argument') const mockFetch = vi.fn()
expect(store.allStatuses.get('1')).to.have.property(property, negate) mockFetch.mockRejectedValueOnce(new Error('Failure!'))
if (count) {
expect(store.allStatuses.get('1')).to.have.property(count, oldCount)
}
// Failing 'bookmark' method SHOULD clear folder id expect(store.allStatuses.get('1')).to.have.property(property, negate)
if (method === 'unbookmark') { if (count) {
expect(store.allStatuses.get('1')).to.have.property( expect(store.allStatuses.get('1')).to.have.property(count, oldCount)
'bookmark_folder_id', }
'argument', vi.stubGlobal('fetch', mockFetch)
)
} await store[method]('1', 'argument')
}) expect(store.allStatuses.get('1')).to.have.property(property, negate)
if (count) {
expect(store.allStatuses.get('1')).to.have.property(count, oldCount)
}
// Failing 'bookmark' method SHOULD clear folder id
if (method === 'unbookmark') {
expect(store.allStatuses.get('1')).to.have.property(
'bookmark_folder_id',
'argument',
)
}
},
)
it.each([ it.each([
['reactWithEmoji', 0], ['reactWithEmoji', 0],

View file

@ -1180,28 +1180,27 @@ describe('Users store', () => {
) )
}) })
it.each([ it.each(['unmute', 'unblock', 'removeUserFromFollowers'])(
'unmute', '%s',
'unblock', async (action) => {
'removeUserFromFollowers', const mockFetch = vi.fn().mockResolvedValueOnce(
])('%s', async (action) => { new Response(JSON.stringify({ id: userId }), {
const mockFetch = vi.fn().mockResolvedValueOnce( headers: { 'Content-Type': 'application/json' },
new Response(JSON.stringify({ id: userId }), { }),
headers: { 'Content-Type': 'application/json' }, )
}),
)
vi.stubGlobal('fetch', mockFetch) vi.stubGlobal('fetch', mockFetch)
const store = useUsersStore() const store = useUsersStore()
const { storeAction, apiUrl } = actionKeys(action) const { storeAction, apiUrl } = actionKeys(action)
await store[storeAction](userId) await store[storeAction](userId)
expect(mockFetch).to.have.been.calledWith( expect(mockFetch).to.have.been.calledWith(
USER_API[apiUrl](userId), USER_API[apiUrl](userId),
DEFAULT_OPTIONS(), DEFAULT_OPTIONS(),
) )
}) },
)
describe.each(['mute', 'block'])('%s', (action) => { describe.each(['mute', 'block'])('%s', (action) => {
it('normal', async () => { it('normal', async () => {

6305
yarn.lock

File diff suppressed because it is too large Load diff