@@ -23,6 +23,91 @@ describe('fn:getMetadata', () => {
2323 createdTime : '2020-01-01T00:00:00Z' ,
2424 lastEditedTime : '2020-01-01T00:00:00Z' ,
2525 url : 'https://www.notion.so/workspace/page' ,
26+ coverImage : 'https://www.notion.so/cover.png' ,
27+ iconEmoji : '📚' ,
28+ iconImage : null ,
2629 } ) ;
2730 } ) ;
31+
32+ it ( 'return null if no cover is set' , ( ) => {
33+ expect ( getMetadata ( { ...examples . page , cover : null } ) ) . toEqual (
34+ expect . objectContaining ( { coverImage : null } ) ,
35+ ) ;
36+ } ) ;
37+
38+ it ( 'return the file url if the cover is embedded' , ( ) => {
39+ expect (
40+ getMetadata ( {
41+ ...examples . page ,
42+ cover : {
43+ type : 'file' ,
44+ file : {
45+ url : 'url' ,
46+ expiry_time : '2020-01-01T00:00:00Z' ,
47+ } ,
48+ } ,
49+ } ) ,
50+ ) . toEqual ( expect . objectContaining ( { coverImage : 'url' } ) ) ;
51+ } ) ;
52+
53+ it ( 'return the file url if the cover is external' , ( ) => {
54+ expect (
55+ getMetadata ( {
56+ ...examples . page ,
57+ cover : {
58+ type : 'external' ,
59+ external : {
60+ url : 'url' ,
61+ } ,
62+ } ,
63+ } ) ,
64+ ) . toEqual ( expect . objectContaining ( { coverImage : 'url' } ) ) ;
65+ } ) ;
66+
67+ it ( 'return null if no icon is set' , ( ) => {
68+ expect ( getMetadata ( { ...examples . page , icon : null } ) ) . toEqual (
69+ expect . objectContaining ( { iconEmoji : null , iconImage : null } ) ,
70+ ) ;
71+ } ) ;
72+
73+ it ( 'return the emoji string if the icon is set as an emoji' , ( ) => {
74+ expect (
75+ getMetadata ( {
76+ ...examples . page ,
77+ icon : {
78+ type : 'emoji' ,
79+ emoji : '☀️' ,
80+ } ,
81+ } ) ,
82+ ) . toEqual ( expect . objectContaining ( { iconEmoji : '☀️' , iconImage : null } ) ) ;
83+ } ) ;
84+
85+ it ( 'return the file url if the icon is embedded' , ( ) => {
86+ expect (
87+ getMetadata ( {
88+ ...examples . page ,
89+ icon : {
90+ type : 'file' ,
91+ file : {
92+ url : 'url' ,
93+ expiry_time : '2020-01-01T00:00:00Z' ,
94+ } ,
95+ } ,
96+ } ) ,
97+ ) . toEqual ( expect . objectContaining ( { iconEmoji : null , iconImage : 'url' } ) ) ;
98+ } ) ;
99+
100+ it ( 'return the file url if the icon is external' , ( ) => {
101+ expect (
102+ getMetadata ( {
103+ ...examples . page ,
104+ icon : {
105+ type : 'external' ,
106+ external : {
107+ url : 'url' ,
108+ } ,
109+ } ,
110+ } ) ,
111+ ) . toEqual ( expect . objectContaining ( { iconEmoji : null , iconImage : 'url' } ) ) ;
112+ } ) ;
28113} ) ;
0 commit comments