Skip to content

Commit

Permalink
Merge pull request #20 from JHWelch/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
JHWelch authored Aug 5, 2023
2 parents f411adf + 2707b40 commit 9f3dc21
Show file tree
Hide file tree
Showing 9 changed files with 1,089 additions and 1,307 deletions.
2 changes: 1 addition & 1 deletion __mocks__/@notionhq/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { jest } from '@jest/globals'
module.exports = {
Client: jest.fn(),

isFullPage: jest.fn(),
isFullPageOrDatabase: jest.fn(),
}
4 changes: 2 additions & 2 deletions __tests__/controllers/weekController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('index', () => {
let req: Request

beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
notionMock.mockQuery([
NotionMock.mockWeek('id1', '2021-01-01', 'theme1'),
NotionMock.mockWeek('id2', '2021-01-08', 'theme2'),
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('index', () => {
let req: Request

beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
notionMock.mockQuery([
NotionMock.mockWeek('weekId3','2021-01-15', 'theme3'),
NotionMock.mockWeek('weekId2','2021-01-08', 'theme2'),
Expand Down
12 changes: 6 additions & 6 deletions __tests__/data/notion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('getMovie', () => {

describe('when the movie exists', () => {
beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
})

it('should return the movie', async () => {
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('getMovie', () => {

describe('returns not full page', () => {
beforeEach(() => {
notionMock.mockIsFullPage(false)
notionMock.mockIsFullPageOrDatabase(false)
})

it('should throw an error', async () => {
Expand All @@ -114,7 +114,7 @@ describe('getWeek', () => {

describe('when the week exists', () => {
beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
})

it('should return the week', async () => {
Expand All @@ -133,7 +133,7 @@ describe('getWeek', () => {

describe('when the week does not exist', () => {
beforeEach(() => {
notionMock.mockIsFullPage(false)
notionMock.mockIsFullPageOrDatabase(false)
})

it('should throw an error', async () => {
Expand All @@ -148,7 +148,7 @@ describe('getWeek', () => {
describe('getUpcomingWeeks', () => {
describe('when the weeks exist', () => {
beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
notionMock.mockQuery([
NotionMock.mockWeek('weekId1','2021-01-01', 'theme1'),
NotionMock.mockWeek('weekId2','2021-01-08', 'theme2'),
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('getUpcomingWeeks', () => {

describe ('getPastWeeks', () => {
beforeEach(() => {
notionMock.mockIsFullPage(true)
notionMock.mockIsFullPageOrDatabase(true)
notionMock.mockQuery([
NotionMock.mockWeek('weekId3','2021-01-15', 'theme3'),
NotionMock.mockWeek('weekId2','2021-01-08', 'theme2'),
Expand Down
1 change: 1 addition & 0 deletions __tests__/support/notionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const pageObjectResponse = (
parent: { type: 'database_id', database_id: '' },
icon: null,
cover: null,
public_url: '',
last_edited_by: {
id: 'string',
object: 'user',
Expand Down
12 changes: 6 additions & 6 deletions __tests__/support/notionMock.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { jest } from '@jest/globals'
import { Client, isFullPage } from '@notionhq/client'
import { Client, isFullPageOrDatabase } from '@notionhq/client'
import { GetPageParameters, GetPageResponse, PageObjectResponse, QueryDatabaseParameters, QueryDatabaseResponse } from '@notionhq/client/build/src/api-endpoints'
import { WithAuth, nCheckbox, nDate, nNumber, nRelation, nRichText, nTitle, nUrl, pageObjectResponse } from './notionHelpers'

export class NotionMock {
query: jest.MockedFunction<typeof Client.prototype.databases.query> | undefined
retrieve: jest.MockedFunction<typeof Client.prototype.pages.retrieve> | undefined
isFullPage: jest.MockedFunction<typeof isFullPage> | undefined
isFullPageOrDatabase: jest.MockedFunction<typeof isFullPageOrDatabase> | undefined

mockNotionEnv = () => {
process.env = {
Expand All @@ -15,8 +15,8 @@ export class NotionMock {
}
}

mockIsFullPage = (response: boolean) => {
(isFullPage as unknown as jest.Mock).mockReturnValue(response)
mockIsFullPageOrDatabase = (response: boolean) => {
(isFullPageOrDatabase as unknown as jest.Mock).mockReturnValue(response)
}

mockRetrieve = (
Expand Down Expand Up @@ -59,8 +59,8 @@ export class NotionMock {
this.query = jest.fn<typeof Client.prototype.databases.query>()
.mockImplementation(
async (_args: WithAuth<QueryDatabaseParameters>): Promise<QueryDatabaseResponse> => ({
page: {},
type: 'page',
page_or_database: {},
type: 'page_or_database',
object: 'list',
next_cursor: null,
has_more: false,
Expand Down
Loading

0 comments on commit 9f3dc21

Please sign in to comment.