Skip to content

Commit aa8df0f

Browse files
committed
separate out event type with auth context
1 parent 0c51861 commit aa8df0f

File tree

2 files changed

+209
-34
lines changed

2 files changed

+209
-34
lines changed

spec/v2/providers/firestore.spec.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,23 @@ describe("firestore", () => {
558558
expect(func.run(true as any)).to.eq(2);
559559
expect(func.__endpoint).to.deep.eq(expectedEp);
560560
});
561+
562+
it("calls init function", async () => {
563+
const event: firestore.RawFirestoreEvent = {
564+
...eventBase,
565+
datacontenttype: "application/json",
566+
data: {
567+
oldValue: null,
568+
value: null,
569+
},
570+
};
571+
572+
let hello;
573+
onInit(() => (hello = "world"));
574+
expect(hello).to.be.undefined;
575+
await firestore.onDocumentWrittenWithAuthContext("path", () => null)(event);
576+
expect(hello).to.equal("world");
577+
});
561578
});
562579

563580
describe("onDocumentCreatedWithAuthContext", () => {
@@ -605,6 +622,23 @@ describe("firestore", () => {
605622
expect(func.run(true as any)).to.eq(2);
606623
expect(func.__endpoint).to.deep.eq(expectedEp);
607624
});
625+
626+
it("calls init function", async () => {
627+
const event: firestore.RawFirestoreEvent = {
628+
...eventBase,
629+
datacontenttype: "application/json",
630+
data: {
631+
oldValue: null,
632+
value: null,
633+
},
634+
};
635+
636+
let hello;
637+
onInit(() => (hello = "world"));
638+
expect(hello).to.be.undefined;
639+
await firestore.onDocumentCreatedWithAuthContext("path", () => null)(event);
640+
expect(hello).to.equal("world");
641+
});
608642
});
609643

610644
describe("onDocumentUpdatedWithAuthContext", () => {
@@ -652,6 +686,23 @@ describe("firestore", () => {
652686
expect(func.run(true as any)).to.eq(2);
653687
expect(func.__endpoint).to.deep.eq(expectedEp);
654688
});
689+
690+
it("calls init function", async () => {
691+
const event: firestore.RawFirestoreEvent = {
692+
...eventBase,
693+
datacontenttype: "application/json",
694+
data: {
695+
oldValue: null,
696+
value: null,
697+
},
698+
};
699+
700+
let hello;
701+
onInit(() => (hello = "world"));
702+
expect(hello).to.be.undefined;
703+
await firestore.onDocumentUpdatedWithAuthContext("path", () => null)(event);
704+
expect(hello).to.equal("world");
705+
});
655706
});
656707

657708
describe("onDocumentDeletedWithAuthContext", () => {
@@ -699,6 +750,23 @@ describe("firestore", () => {
699750
expect(func.run(true as any)).to.eq(2);
700751
expect(func.__endpoint).to.deep.eq(expectedEp);
701752
});
753+
754+
it("calls init function", async () => {
755+
const event: firestore.RawFirestoreEvent = {
756+
...eventBase,
757+
datacontenttype: "application/json",
758+
data: {
759+
oldValue: null,
760+
value: null,
761+
},
762+
};
763+
764+
let hello;
765+
onInit(() => (hello = "world"));
766+
expect(hello).to.be.undefined;
767+
await firestore.onDocumentDeletedWithAuthContext("path", () => null)(event);
768+
expect(hello).to.equal("world");
769+
});
702770
});
703771

704772
describe("getOpts", () => {

0 commit comments

Comments
 (0)