| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | |
| 3 | import { parseIssueSearch } |
| 4 | |
| 5 | describe('parseIssueSearch', () |
| 6 | it('reads the qualifiers gh writes for issue list --search', |
| 7 | expect( |
| 8 | parseIssueSearch( |
| 9 | 'repo:ada/tools is:issue is:open label:bug label:"help wanted" author:ada assignee:bob crash on start', |
| 10 | ), |
| 11 | ).toEqual({ |
| 12 | repo: { owner: ' |
| 13 | state: 'open', |
| 14 | isPullRequest: false, |
| 15 | author: 'ada', |
| 16 | assignee: 'bob', |
| 17 | labels: ['bug', |
| 18 | merged: null, |
| 19 | reviewRequested: undefined, |
| 20 | text: 'crash on start', |
| 21 | }); |
| 22 | }); |
| 23 | |
| 24 | it('ignores qualifiers Ghost cannot filter on instead of failing', |
| 25 | expect( |
| 26 | parseIssueSearch( |
| 27 | 'repo:ada/tools milestone:v1 reason:completed sort:created-desc type:issue state:closed fix', |
| 28 | ), |
| 29 | ).toMatchObject({ |
| 30 | state: 'closed', |
| 31 | isPullRequest: false, |
| 32 | labels: [], |
| 33 | text: 'fix', |
| 34 | }); |
| 35 | }); |
| 36 | |
| 37 | it('reads the qualifiers gh writes for pr status', |
| 38 | expect( |
| 39 | parseIssueSearch( |
| 40 | 'repo:ada/tools state:open is:pr is:merged author:@me review-requested:@me', |
| 41 | ), |
| 42 | ).toMatchObject({ |
| 43 | isPullRequest: true, |
| 44 | merged: true, |
| 45 | author: '@me', |
| 46 | reviewRequested: '@me', |
| 47 | }); |
| 48 | }); |
| 49 | |
| 50 | it('defaults to every state and both kinds', |
| 51 | expect(parseIssueSearch('repo:ada/tools |
| 52 | state: 'all', |
| 53 | isPullRequest: null, |
| 54 | text: '', |
| 55 | }); |
| 56 | }); |
| 57 | }); |