Files
orca/src/main/github/comment-reactions.test.ts
T
Jinwoo HongandJinwoo-H 158212b8b3 feat(github): add PR comment reactions (#13470)
* feat(github): add PR comment reactions

* fix(github): harden comment reaction updates

---------

Co-authored-by: Jinwoo-H <Jinwoo-H@users.noreply.github.com>
2026-08-09 22:11:54 -07:00

31 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { mapGraphQLReactionGroups, toGraphQLReactionContent } from './comment-reactions'
describe('mapGraphQLReactionGroups', () => {
it('normalizes GraphQL reaction groups into GitHub comment reactions', () => {
expect(
mapGraphQLReactionGroups([
{ content: 'EYES', reactors: { totalCount: 1 }, viewerHasReacted: false },
{ content: 'THUMBS_UP', reactors: { totalCount: 2 }, viewerHasReacted: true },
{ content: 'HEART', reactors: { totalCount: 0 } },
{ content: 'UNKNOWN', reactors: { totalCount: 9 } }
])
).toEqual([
{ content: '+1', count: 2, viewerHasReacted: true },
{ content: 'eyes', count: 1, viewerHasReacted: false }
])
})
it('returns undefined when there are no visible reactions', () => {
expect(mapGraphQLReactionGroups([{ content: 'ROCKET', reactors: { totalCount: 0 } }])).toBe(
undefined
)
})
it('maps REST reaction content to the GraphQL enum', () => {
expect(toGraphQLReactionContent('+1')).toBe('THUMBS_UP')
expect(toGraphQLReactionContent('hooray')).toBe('HOORAY')
})
})