1
- import { Page } from "@notionhq/client/build/src/api-types" ;
2
- import { PropertiesParser } from "./PropertiesParser" ;
3
- import { RichTextRenderer } from "./RichTextRenderer" ;
4
- import { DatabaseConfig } from "./SyncConfig" ;
1
+ import { Page } from '@notionhq/client/build/src/api-types' ;
2
+
3
+ import { PropertiesParser } from './PropertiesParser' ;
4
+ import { RichTextRenderer } from './RichTextRenderer' ;
5
+ import { DatabaseConfig } from './SyncConfig' ;
5
6
6
7
const page : Partial < Page > = {
7
8
id : "123" ,
@@ -35,31 +36,28 @@ describe("PropertiesParser", () => {
35
36
describe ( "parse" , ( ) => {
36
37
37
38
test ( "preserves all properties and adds conventional with no include filter" , async ( ) => {
38
- const sut = new PropertiesParser ( new RichTextRenderer ( ) ) ;
39
+ const sut = new PropertiesParser ( new RichTextRenderer ( { } as any , { } as any ) ) ;
39
40
40
41
const config : DatabaseConfig = {
41
42
outDir : "db/" ,
42
- properties : {
43
- category : "Category" ,
44
- } ,
43
+ renderAs : 'table' ,
44
+ entries : {
45
+ emitToIndex : false
46
+ }
45
47
} ;
46
48
47
- const result = sut . parse ( page as any , config ) ;
49
+ const result = await sut . parseProperties ( page as any , config ) ;
48
50
49
51
const expected = {
50
- meta : {
51
- category : "Tools" ,
52
- id : "123" ,
53
- title : "Terraform" ,
54
- url : "http://example.com/123" ,
55
- order : 30
56
- } ,
52
+ category : null ,
53
+ order : 30 ,
54
+ title : "Terraform" ,
57
55
keys : new Map ( [
58
56
[ "order" , "order" ] ,
59
57
[ "Category" , "category" ] ,
60
58
[ "Name" , "name" ] ,
61
59
] ) ,
62
- values : {
60
+ properties : {
63
61
order : 30 ,
64
62
category : "Tools" ,
65
63
name : "Terraform" ,
@@ -69,31 +67,30 @@ describe("PropertiesParser", () => {
69
67
} ) ;
70
68
71
69
test ( "filters according to include filter" , async ( ) => {
72
- const sut = new PropertiesParser ( new RichTextRenderer ( ) ) ;
70
+ const sut = new PropertiesParser ( new RichTextRenderer ( { } as any , { } as any ) ) ;
73
71
74
72
const config : DatabaseConfig = {
75
73
outDir : "db/" ,
74
+ renderAs : "table" ,
76
75
properties : {
77
- category : "Category" ,
78
76
include : [ "Name" , "Category" ] ,
79
77
} ,
78
+ entries : {
79
+ emitToIndex : false
80
+ }
80
81
} ;
81
82
82
- const result = sut . parse ( page as any , config ) ;
83
-
83
+ const result = await sut . parseProperties ( page as any , config ) ;
84
+
84
85
const expected = {
85
- meta : {
86
- category : "Tools" ,
87
- id : "123" ,
88
- title : "Terraform" ,
89
- url : "http://example.com/123" ,
90
- order : 30
91
- } ,
86
+ category : null ,
87
+ order : 30 ,
88
+ title : "Terraform" ,
92
89
keys : new Map ( [
93
- [ "Name" , "name" ] ,
94
90
[ "Category" , "category" ] ,
91
+ [ "Name" , "name" ] ,
95
92
] ) ,
96
- values : {
93
+ properties : {
97
94
category : "Tools" ,
98
95
name : "Terraform" ,
99
96
} ,
0 commit comments