|
1 |
| -import { extractSentrytraceData } from '../src/utils'; |
| 1 | +import { extractSentrytraceData, extractTracestateData } from '../src/utils'; |
2 | 2 |
|
3 | 3 | describe('extractSentrytraceData', () => {
|
4 | 4 | test('no sample', () => {
|
@@ -62,3 +62,59 @@ describe('extractSentrytraceData', () => {
|
62 | 62 | expect(extractSentrytraceData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-x')).toBeUndefined();
|
63 | 63 | });
|
64 | 64 | });
|
| 65 | + |
| 66 | +describe('extractTracestateData', () => { |
| 67 | + it.each([ |
| 68 | + // sentry only |
| 69 | + ['sentry only', 'sentry=doGsaREgReaT', 'sentry=doGsaREgReaT', undefined], |
| 70 | + // sentry only, invalid (`!` isn't a valid base64 character) |
| 71 | + ['sentry only, invalid', 'sentry=doGsaREgReaT!', undefined, undefined], |
| 72 | + // stuff before |
| 73 | + ['stuff before', 'maisey=silly,sentry=doGsaREgReaT', 'sentry=doGsaREgReaT', 'maisey=silly'], |
| 74 | + // stuff after |
| 75 | + ['stuff after', 'sentry=doGsaREgReaT,maisey=silly', 'sentry=doGsaREgReaT', 'maisey=silly'], |
| 76 | + // stuff before and after |
| 77 | + [ |
| 78 | + 'stuff before and after', |
| 79 | + 'charlie=goofy,sentry=doGsaREgReaT,maisey=silly', |
| 80 | + 'sentry=doGsaREgReaT', |
| 81 | + 'charlie=goofy,maisey=silly', |
| 82 | + ], |
| 83 | + // multiple before |
| 84 | + [ |
| 85 | + 'multiple before', |
| 86 | + 'charlie=goofy,maisey=silly,sentry=doGsaREgReaT', |
| 87 | + 'sentry=doGsaREgReaT', |
| 88 | + 'charlie=goofy,maisey=silly', |
| 89 | + ], |
| 90 | + // multiple after |
| 91 | + [ |
| 92 | + 'multiple after', |
| 93 | + 'sentry=doGsaREgReaT,charlie=goofy,maisey=silly', |
| 94 | + 'sentry=doGsaREgReaT', |
| 95 | + 'charlie=goofy,maisey=silly', |
| 96 | + ], |
| 97 | + // multiple before and after |
| 98 | + [ |
| 99 | + 'multiple before and after', |
| 100 | + 'charlie=goofy,maisey=silly,sentry=doGsaREgReaT,bodhi=floppy,cory=loyal', |
| 101 | + 'sentry=doGsaREgReaT', |
| 102 | + 'charlie=goofy,maisey=silly,bodhi=floppy,cory=loyal', |
| 103 | + ], |
| 104 | + // only third-party data |
| 105 | + ['only third-party data', 'maisey=silly', undefined, 'maisey=silly'], |
| 106 | + // invalid third-party data, valid sentry data |
| 107 | + [ |
| 108 | + 'invalid third-party data, valid sentry data', |
| 109 | + 'maisey_is_silly,sentry=doGsaREgReaT', |
| 110 | + 'sentry=doGsaREgReaT', |
| 111 | + undefined, |
| 112 | + ], |
| 113 | + // valid third party data, invalid sentry data |
| 114 | + ['valid third-party data, invalid sentry data', 'maisey=silly,sentry=doGsaREgReaT!', undefined, 'maisey=silly'], |
| 115 | + // nothing valid at all |
| 116 | + ['nothing valid at all', 'maisey_is_silly,sentry=doGsaREgReaT!', undefined, undefined], |
| 117 | + ])('%s', (_testTitle: string, header: string, sentry?: string, thirdparty?: string): void => { |
| 118 | + expect(extractTracestateData(header)).toEqual({ sentry, thirdparty }); |
| 119 | + }); |
| 120 | +}); |
0 commit comments