mirror of https://github.com/Budibase/budibase.git
8 changed files with 84 additions and 8 deletions
@ -0,0 +1,40 @@ |
|||
import PosthogProcessor from "../PosthogProcessor" |
|||
import { Event, IdentityType, Hosting } from "@budibase/types" |
|||
|
|||
const newIdentity = () => { |
|||
return { |
|||
id: "test", |
|||
type: IdentityType.USER, |
|||
hosting: Hosting.SELF, |
|||
environment: "test", |
|||
} |
|||
} |
|||
|
|||
describe("PosthogProcessor", () => { |
|||
beforeEach(() => { |
|||
jest.clearAllMocks() |
|||
}) |
|||
|
|||
describe("processEvent", () => { |
|||
it("processes event", () => { |
|||
const processor = new PosthogProcessor("test") |
|||
|
|||
const identity = newIdentity() |
|||
const properties = {} |
|||
|
|||
processor.processEvent(Event.APP_CREATED, identity, properties) |
|||
|
|||
expect(processor.posthog.capture).toHaveBeenCalledTimes(1) |
|||
}) |
|||
|
|||
it("honours exclusions", () => { |
|||
const processor = new PosthogProcessor("test") |
|||
|
|||
const identity = newIdentity() |
|||
const properties = {} |
|||
|
|||
processor.processEvent(Event.AUTH_SSO_UPDATED, identity, properties) |
|||
expect(processor.posthog.capture).toHaveBeenCalledTimes(0) |
|||
}) |
|||
}) |
|||
}) |
|||
@ -1,7 +1,9 @@ |
|||
const posthog = require("./posthog") |
|||
const events = require("./events") |
|||
const date = require("./date") |
|||
|
|||
module.exports = { |
|||
posthog, |
|||
date, |
|||
events, |
|||
} |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
jest.mock("posthog-node", () => { |
|||
return jest.fn().mockImplementation(() => { |
|||
return { |
|||
capture: jest.fn(), |
|||
} |
|||
}) |
|||
}) |
|||
Loading…
Reference in new issue