|
| 1 | +import type { CheckIn } from '@sentry/types'; |
| 2 | + |
1 | 3 | import { createCheckInEnvelope } from '../src/checkin';
|
2 | 4 |
|
3 |
| -describe('userFeedback', () => { |
4 |
| - test('creates user feedback envelope header', () => { |
| 5 | +describe('CheckIn', () => { |
| 6 | + test('creates a check in envelope header', () => { |
5 | 7 | const envelope = createCheckInEnvelope(
|
6 | 8 | {
|
7 | 9 | check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244',
|
@@ -32,29 +34,93 @@ describe('userFeedback', () => {
|
32 | 34 | });
|
33 | 35 | });
|
34 | 36 |
|
35 |
| - test('creates user feedback envelope item', () => { |
36 |
| - const envelope = createCheckInEnvelope({ |
37 |
| - check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
38 |
| - monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
39 |
| - status: 'ok', |
40 |
| - duration: 10.0, |
41 |
| - release: '1.0.0', |
42 |
| - environment: 'production', |
43 |
| - }); |
| 37 | + test.each([ |
| 38 | + [ |
| 39 | + 'no monitor config', |
| 40 | + { |
| 41 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 42 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 43 | + status: 'ok', |
| 44 | + duration: 10.0, |
| 45 | + release: '1.0.0', |
| 46 | + environment: 'production', |
| 47 | + } as CheckIn, |
| 48 | + { |
| 49 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 50 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 51 | + status: 'ok', |
| 52 | + duration: 10.0, |
| 53 | + release: '1.0.0', |
| 54 | + environment: 'production', |
| 55 | + }, |
| 56 | + ], |
| 57 | + [ |
| 58 | + 'crontab monitor config', |
| 59 | + { |
| 60 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 61 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 62 | + status: 'in_progress', |
| 63 | + monitor_config: { |
| 64 | + schedule: { |
| 65 | + type: 'crontab', |
| 66 | + value: '0 * * * *', |
| 67 | + }, |
| 68 | + checkin_margin: 5, |
| 69 | + max_runtime: 30, |
| 70 | + timezone: 'America/Los_Angeles', |
| 71 | + }, |
| 72 | + } as CheckIn, |
| 73 | + { |
| 74 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 75 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 76 | + status: 'in_progress', |
| 77 | + monitor_config: { |
| 78 | + schedule: { |
| 79 | + type: 'crontab', |
| 80 | + value: '0 * * * *', |
| 81 | + }, |
| 82 | + checkin_margin: 5, |
| 83 | + max_runtime: 30, |
| 84 | + timezone: 'America/Los_Angeles', |
| 85 | + }, |
| 86 | + }, |
| 87 | + ], |
| 88 | + [ |
| 89 | + 'interval monitor config', |
| 90 | + { |
| 91 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 92 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 93 | + status: 'in_progress', |
| 94 | + monitor_config: { |
| 95 | + schedule: { |
| 96 | + type: 'interval', |
| 97 | + value: 1234, |
| 98 | + unit: 'minute', |
| 99 | + }, |
| 100 | + }, |
| 101 | + } as CheckIn, |
| 102 | + { |
| 103 | + check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
| 104 | + monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
| 105 | + status: 'in_progress', |
| 106 | + monitor_config: { |
| 107 | + schedule: { |
| 108 | + type: 'interval', |
| 109 | + value: 1234, |
| 110 | + unit: 'minute', |
| 111 | + }, |
| 112 | + }, |
| 113 | + }, |
| 114 | + ], |
| 115 | + ])('creates a check in envelope header with %s', (_, checkIn, envelopeItem) => { |
| 116 | + const envelope = createCheckInEnvelope(checkIn); |
44 | 117 |
|
45 | 118 | expect(envelope[1]).toEqual([
|
46 | 119 | [
|
47 | 120 | {
|
48 | 121 | type: 'check_in',
|
49 | 122 | },
|
50 |
| - { |
51 |
| - check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', |
52 |
| - monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', |
53 |
| - status: 'ok', |
54 |
| - duration: 10.0, |
55 |
| - release: '1.0.0', |
56 |
| - environment: 'production', |
57 |
| - }, |
| 123 | + envelopeItem, |
58 | 124 | ],
|
59 | 125 | ]);
|
60 | 126 | });
|
|
0 commit comments