Skip to content

Commit bdc81ee

Browse files
committed
Fix imports and mocks for renamed functions in tests
1 parent 82feb43 commit bdc81ee

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

bin/worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { reportRequestMetric as defaultReportRequestMetric } from '../lib/influx.js'
1+
import { reportRequestMetrics as defaultReportRequestMetric } from '../lib/influx.js'
22

33
export default {
4-
async fetch(request, env, ctx, { reportRequestMetric = defaultReportRequestMetric } = {}) {
4+
async fetch(request, env, ctx, { reportRequestMetrics = defaultReportRequestMetric } = {}) {
55
const response = await fetch(request)
6-
ctx.waitUntil(reportRequestMetric(request, env))
6+
ctx.waitUntil(reportRequestMetrics(request, env))
77
return response
88
},
99
}

test/influx.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2-
import { createMetricsFromRequest, writeMetrics, reportRequestMetric } from '../lib/influx.js'
2+
import { createMetricsFromRequest, writeMetrics, reportRequestMetrics } from '../lib/influx.js'
33

4-
describe('reportRequestMetric', () => {
4+
describe('reportRequestMetrics', () => {
55
const date = new Date()
66

77
beforeEach(() => {
@@ -22,7 +22,7 @@ describe('reportRequestMetric', () => {
2222
}
2323
global.fetch = vi.fn().mockResolvedValue(new Response(null, { status: 204 }));
2424

25-
await reportRequestMetric(request, env);
25+
await reportRequestMetrics(request, env);
2626

2727
expect(global.fetch).toHaveBeenCalledWith(
2828
'https://influx.example.com/api/v2/write?&bucket=test_db&precision=ms',

test/worker.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ describe('worker.fetch', () => {
1212
waitUntil: vi.fn()
1313
};
1414
global.fetch = vi.fn().mockResolvedValue(new Response(null, { status: 200 }));
15-
const reportRequestMetric = vi.fn()
16-
const response = await worker.fetch(request, env, ctx, { reportRequestMetric });
15+
const reportRequestMetrics = vi.fn()
16+
const response = await worker.fetch(request, env, ctx, { reportRequestMetrics });
1717
expect(global.fetch).toHaveBeenCalledWith(request);
18-
expect(reportRequestMetric).toHaveBeenCalledWith(request, env);
19-
expect(ctx.waitUntil).toHaveBeenCalledWith(reportRequestMetric(request, env));
18+
expect(reportRequestMetrics).toHaveBeenCalledWith(request, env);
19+
expect(ctx.waitUntil).toHaveBeenCalledWith(reportRequestMetrics(request, env));
2020
expect(response.status).toBe(200);
2121
});
2222
});

0 commit comments

Comments
 (0)