Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Apr 10, 2024
1 parent bcacfa0 commit 1a03280
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/__tests__/page-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jest.mock('../utils/globals', () => ({

describe('PageView ID manager', () => {
describe('doPageView', () => {
const instance: PostHog = {
config: {},
} as any
instance.scrollManager = new ScrollManager(instance)
let instance: PostHog

beforeEach(() => {
instance = {
config: {},
} as any
instance.scrollManager = new ScrollManager(instance)
mockWindowGetter.mockReturnValue({
location: {
pathname: '/pathname',
Expand Down Expand Up @@ -52,7 +53,7 @@ describe('PageView ID manager', () => {
pageViewIdManager.doPageView()

// force the manager to update the scroll data by calling an internal method
instance.scrollManager._updateScrollData()
instance.scrollManager['_updateScrollData']()

const secondPageView = pageViewIdManager.doPageView()
expect(secondPageView.$prev_pageview_last_scroll).toEqual(2000)
Expand Down Expand Up @@ -83,7 +84,7 @@ describe('PageView ID manager', () => {
pageViewIdManager.doPageView()

// force the manager to update the scroll data by calling an internal method
instance.scrollManager._updateScrollData()
instance.scrollManager['_updateScrollData']()

const secondPageView = pageViewIdManager.doPageView()
expect(secondPageView.$prev_pageview_last_scroll).toEqual(0)
Expand All @@ -99,7 +100,7 @@ describe('PageView ID manager', () => {
it('can handle scroll updates before doPageView is called', () => {
const pageViewIdManager = new PageViewManager(instance)

instance.scrollManager._updateScrollData()
instance.scrollManager['_updateScrollData']()
const firstPageView = pageViewIdManager.doPageView()
expect(firstPageView.$prev_pageview_last_scroll).toBeUndefined()

Expand Down

0 comments on commit 1a03280

Please sign in to comment.