|
| 1 | +import {describe, it, expect} from 'vitest' |
| 2 | +import {CheckInfo} from '../src/annotator.js' |
| 3 | + |
| 4 | +/** |
| 5 | + * Copyright 2024 Mike Penz |
| 6 | + */ |
| 7 | + |
| 8 | +describe('report_url output', () => { |
| 9 | + it('should format single URL correctly', () => { |
| 10 | + const checkInfos: CheckInfo[] = [ |
| 11 | + { |
| 12 | + name: 'Test Report 1', |
| 13 | + url: 'https://github.com/owner/repo/runs/123' |
| 14 | + } |
| 15 | + ] |
| 16 | + |
| 17 | + const reportUrls = checkInfos.map(info => info.url).join('\n') |
| 18 | + expect(reportUrls).toBe('https://github.com/owner/repo/runs/123') |
| 19 | + }) |
| 20 | + |
| 21 | + it('should format multiple URLs with newline separation', () => { |
| 22 | + const checkInfos: CheckInfo[] = [ |
| 23 | + { |
| 24 | + name: 'Test Report 1', |
| 25 | + url: 'https://github.com/owner/repo/runs/123' |
| 26 | + }, |
| 27 | + { |
| 28 | + name: 'Test Report 2', |
| 29 | + url: 'https://github.com/owner/repo/runs/456' |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'Test Report 3', |
| 33 | + url: 'https://github.com/owner/repo/runs/789' |
| 34 | + } |
| 35 | + ] |
| 36 | + |
| 37 | + const reportUrls = checkInfos.map(info => info.url).join('\n') |
| 38 | + expect(reportUrls).toBe( |
| 39 | + 'https://github.com/owner/repo/runs/123\nhttps://github.com/owner/repo/runs/456\nhttps://github.com/owner/repo/runs/789' |
| 40 | + ) |
| 41 | + }) |
| 42 | + |
| 43 | + it('should handle empty checkInfos array', () => { |
| 44 | + const checkInfos: CheckInfo[] = [] |
| 45 | + |
| 46 | + const reportUrls = checkInfos.map(info => info.url).join('\n') |
| 47 | + expect(reportUrls).toBe('') |
| 48 | + }) |
| 49 | +}) |
0 commit comments