Skip to content

Commit 49d3bf5

Browse files
Add unit test to verify FileObject & IPageIcon ✅
1 parent 07d98b2 commit 49d3bf5

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public async Task RetrieveDatabaseAsync()
119119
{
120120
property.Key.Should().Be(property.Value.Name);
121121
}
122+
123+
HelperAsserts.IPageIconAsserts(database.Icon);
124+
HelperAsserts.FileObjectAsserts(database.Cover);
122125
}
123126

124127
[Fact]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using FluentAssertions;
2+
using Notion.Client;
3+
4+
namespace Notion.UnitTests
5+
{
6+
public static class HelperAsserts
7+
{
8+
public static void IPageIconAsserts(IPageIcon icon)
9+
{
10+
icon.Should().NotBeNull();
11+
12+
switch (icon)
13+
{
14+
case EmojiObject emoji:
15+
emoji.Emoji.Should().NotBeNull();
16+
break;
17+
case FileObject fileObject:
18+
FileObjectAsserts(fileObject);
19+
break;
20+
}
21+
}
22+
23+
public static void FileObjectAsserts(FileObject fileObject)
24+
{
25+
fileObject.Should().NotBeNull();
26+
27+
switch (fileObject)
28+
{
29+
case UploadedFile uploadedFile:
30+
uploadedFile.File.Should().NotBeNull();
31+
uploadedFile.File.Url.Should().NotBeNull();
32+
uploadedFile.File.ExpiryTime.Should().NotBeSameDateAs(default);
33+
break;
34+
case ExternalFile externalFile:
35+
externalFile.External.Should().NotBeNull();
36+
externalFile.External.Url.Should().NotBeNull();
37+
break;
38+
}
39+
}
40+
}
41+
}

Test/Notion.UnitTests/data/databases/DatabaseRetrieveResponse.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
"href": null
2323
}
2424
],
25+
"icon": {
26+
"type": "emoji",
27+
"emoji": "🎉"
28+
},
29+
"cover": {
30+
"type": "external",
31+
"external": {
32+
"url": "https://website.domain/images/image.png"
33+
}
34+
},
35+
"url": "https://www.notion.so/668d797c76fa49349b05ad288df2d136",
2536
"properties": {
2637
"Tags": {
2738
"id": "YG~h",

0 commit comments

Comments
 (0)