cf-bun-mocks 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-bun-mocks",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Cloudflare Workers mocks and helpers for Bun testing",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/d1.ts CHANGED
@@ -110,7 +110,7 @@ class D1DatabaseSessionMock implements D1DatabaseSession {
110
110
  }
111
111
 
112
112
  export class D1Mock implements D1Database {
113
- #db: Database;
113
+ db: Database;
114
114
 
115
115
  constructor(
116
116
  filename?: string,
@@ -124,11 +124,11 @@ export class D1Mock implements D1Database {
124
124
  strict?: boolean;
125
125
  }
126
126
  ) {
127
- this.#db = new Database(filename, options);
127
+ this.db = new Database(filename, options);
128
128
  }
129
129
 
130
130
  prepare(query: string): D1PreparedStatement {
131
- const stmt = this.#db.prepare(query);
131
+ const stmt = this.db.prepare(query);
132
132
  return new D1PreparedStatementMock(stmt);
133
133
  }
134
134
 
@@ -148,7 +148,7 @@ export class D1Mock implements D1Database {
148
148
  async exec(query: string): Promise<D1ExecResult> {
149
149
  const start = performance.now();
150
150
  try {
151
- const { changes: count } = this.#db.run(query);
151
+ const { changes: count } = this.db.run(query);
152
152
  const duration = performance.now() - start;
153
153
  return {
154
154
  count,
@@ -170,7 +170,7 @@ export class D1Mock implements D1Database {
170
170
  }
171
171
 
172
172
  async dump(): Promise<ArrayBuffer> {
173
- const serialized = this.#db.serialize();
173
+ const serialized = this.db.serialize();
174
174
  const buffer = serialized.buffer;
175
175
  if (buffer instanceof SharedArrayBuffer) {
176
176
  const newBuffer = new ArrayBuffer(buffer.byteLength);
package/src/workers.ts CHANGED
@@ -30,4 +30,6 @@ export function useWorkersEnv<TEnv extends Cloudflare.Env = Cloudflare.Env>(
30
30
  afterAll(() => {
31
31
  moduleMock.env = {};
32
32
  });
33
+
34
+ return moduleMock.env;
33
35
  }