Skip to content

Commit

Permalink
separate out event type with auth context
Browse files Browse the repository at this point in the history
  • Loading branch information
blidd-google committed Apr 3, 2024
1 parent 0c51861 commit aa8df0f
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 34 deletions.
68 changes: 68 additions & 0 deletions spec/v2/providers/firestore.spec.ts
Expand Up @@ -558,6 +558,23 @@ describe("firestore", () => {
expect(func.run(true as any)).to.eq(2);
expect(func.__endpoint).to.deep.eq(expectedEp);
});

it("calls init function", async () => {
const event: firestore.RawFirestoreEvent = {
...eventBase,
datacontenttype: "application/json",
data: {
oldValue: null,
value: null,
},
};

let hello;
onInit(() => (hello = "world"));
expect(hello).to.be.undefined;
await firestore.onDocumentWrittenWithAuthContext("path", () => null)(event);
expect(hello).to.equal("world");
});
});

describe("onDocumentCreatedWithAuthContext", () => {
Expand Down Expand Up @@ -605,6 +622,23 @@ describe("firestore", () => {
expect(func.run(true as any)).to.eq(2);
expect(func.__endpoint).to.deep.eq(expectedEp);
});

it("calls init function", async () => {
const event: firestore.RawFirestoreEvent = {
...eventBase,
datacontenttype: "application/json",
data: {
oldValue: null,
value: null,
},
};

let hello;
onInit(() => (hello = "world"));
expect(hello).to.be.undefined;
await firestore.onDocumentCreatedWithAuthContext("path", () => null)(event);
expect(hello).to.equal("world");
});
});

describe("onDocumentUpdatedWithAuthContext", () => {
Expand Down Expand Up @@ -652,6 +686,23 @@ describe("firestore", () => {
expect(func.run(true as any)).to.eq(2);
expect(func.__endpoint).to.deep.eq(expectedEp);
});

it("calls init function", async () => {
const event: firestore.RawFirestoreEvent = {
...eventBase,
datacontenttype: "application/json",
data: {
oldValue: null,
value: null,
},
};

let hello;
onInit(() => (hello = "world"));
expect(hello).to.be.undefined;
await firestore.onDocumentUpdatedWithAuthContext("path", () => null)(event);
expect(hello).to.equal("world");
});
});

describe("onDocumentDeletedWithAuthContext", () => {
Expand Down Expand Up @@ -699,6 +750,23 @@ describe("firestore", () => {
expect(func.run(true as any)).to.eq(2);
expect(func.__endpoint).to.deep.eq(expectedEp);
});

it("calls init function", async () => {
const event: firestore.RawFirestoreEvent = {
...eventBase,
datacontenttype: "application/json",
data: {
oldValue: null,
value: null,
},
};

let hello;
onInit(() => (hello = "world"));
expect(hello).to.be.undefined;
await firestore.onDocumentDeletedWithAuthContext("path", () => null)(event);
expect(hello).to.equal("world");
});
});

describe("getOpts", () => {
Expand Down

0 comments on commit aa8df0f

Please sign in to comment.