-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement page create when passing predicate function
- Loading branch information
1 parent
2b25029
commit 97b9f95
Showing
4 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expect, test, describe } from 'vitest'; | ||
import { PageProperties } from './types'; | ||
import { NotionPage } from './notion-page'; | ||
|
||
class FakeNotionPage<T extends Record<string, PageProperties['type']>> extends NotionPage<T> { | ||
override processCreatePredidcate = super.processCreatePredidcate; | ||
} | ||
|
||
describe('Test processCreatePredidcate', () => { | ||
test('When predicate is plain filter object', () => { | ||
expect( | ||
new FakeNotionPage({ notionClient: {} as any }).processCreatePredidcate({ | ||
properties: { | ||
Test: { | ||
date: { | ||
start: '2022-01-01', | ||
}, | ||
}, | ||
}, | ||
}) | ||
).toStrictEqual({ | ||
properties: { | ||
Test: { | ||
date: { | ||
start: '2022-01-01', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test('When predicate is function, with helper function', () => { | ||
expect( | ||
new FakeNotionPage({ | ||
notionClient: {} as any, | ||
propTypes: { | ||
Test: 'date', | ||
}, | ||
}).processCreatePredidcate(prop => ({ | ||
properties: { | ||
...prop['Test'].params({ | ||
date: { | ||
start: '2022-01-01', | ||
}, | ||
}), | ||
}, | ||
})) | ||
).toStrictEqual({ | ||
properties: { | ||
Test: { | ||
date: { | ||
start: '2022-01-01', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |