Rocky_Mountain_Vending/.pnpm-store/v10/files/eb/e6b7c34db72d6bad6678358535248638b3602ba355ec48d2850236cf74fa475d5b7002732aaa76fac0eacea4adf45311f09236b073cb2268119970b4e5bb93
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

83 lines
No EOL
2.6 KiB
Text

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _posttelemetrypayload = require("./post-telemetry-payload");
describe('postNextTelemetryPayload', ()=>{
let originalFetch;
beforeEach(()=>{
originalFetch = global.fetch;
});
afterEach(()=>{
global.fetch = originalFetch;
});
it('sends telemetry payload successfully', async ()=>{
const mockFetch = jest.fn().mockResolvedValue({
ok: true
});
global.fetch = mockFetch;
const payload = {
meta: {
version: '1.0'
},
context: {
anonymousId: 'test-id',
projectId: 'test-project',
sessionId: 'test-session'
},
events: [
{
eventName: 'test-event',
fields: {
foo: 'bar'
}
}
]
};
await (0, _posttelemetrypayload.postNextTelemetryPayload)(payload);
expect(mockFetch).toHaveBeenCalledWith('https://telemetry.nextjs.org/api/v1/record', {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'content-type': 'application/json'
},
signal: expect.any(AbortSignal)
});
});
it('retries on failure', async ()=>{
const mockFetch = jest.fn().mockRejectedValueOnce(new Error('Network error')).mockResolvedValueOnce({
ok: true
});
global.fetch = mockFetch;
const payload = {
meta: {},
context: {
anonymousId: 'test-id',
projectId: 'test-project',
sessionId: 'test-session'
},
events: []
};
await (0, _posttelemetrypayload.postNextTelemetryPayload)(payload);
expect(mockFetch).toHaveBeenCalledTimes(2);
});
it('swallows errors after retries exhausted', async ()=>{
const mockFetch = jest.fn().mockRejectedValue(new Error('Network error'));
global.fetch = mockFetch;
const payload = {
meta: {},
context: {
anonymousId: 'test-id',
projectId: 'test-project',
sessionId: 'test-session'
},
events: []
};
// Should not throw
await (0, _posttelemetrypayload.postNextTelemetryPayload)(payload);
expect(mockFetch).toHaveBeenCalledTimes(2) // Initial try + 1 retry
;
});
});
//# sourceMappingURL=post-telemetry-payload.test.js.map