Skip to content

Commit ac09562

Browse files
add integration test for retrieve a page endpoint ✅
1 parent 7ec09bc commit ac09562

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Test/Notion.UnitTests/Notion.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
1112
<PackageReference Include="Microsoft.VisualStudio.VsixColorCompiler" Version="16.0.0" />
1213
<PackageReference Include="WireMock.Net" Version="1.4.19" />

Test/Notion.UnitTests/PagesClientTests.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Threading.Tasks;
3+
using FluentAssertions;
34
using Notion.Client;
45
using WireMock.ResponseBuilders;
56
using Xunit;
@@ -15,6 +16,30 @@ public PagesClientTests()
1516
_client = new PagesClient(new RestClient(ClientOptions));
1617
}
1718

19+
[Fact]
20+
public async Task RetrieveAsync()
21+
{
22+
var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c";
23+
var path = ApiEndpoints.PagesApiUrls.Retrieve(pageId);
24+
var jsonData = await File.ReadAllTextAsync("data/pages/PageObjectShouldHaveUrlPropertyResponse.json");
25+
26+
Server.Given(CreateGetRequestBuilder(path))
27+
.RespondWith(
28+
Response.Create()
29+
.WithStatusCode(200)
30+
.WithBody(jsonData)
31+
);
32+
33+
var page = await _client.RetrieveAsync(pageId);
34+
35+
page.Url.Should().Be("https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c");
36+
page.Id.Should().Be(pageId);
37+
page.Parent.Type.Should().Be(ParentType.DatabaseId);
38+
((DatabaseParent)page.Parent).DatabaseId.Should().Be("48f8fee9-cd79-4180-bc2f-ec0398253067");
39+
page.IsArchived.Should().BeFalse();
40+
41+
}
42+
1843
[Fact]
1944
public async Task PageObjectShouldHaveUrlProperty()
2045
{
@@ -31,7 +56,8 @@ public async Task PageObjectShouldHaveUrlProperty()
3156

3257
var page = await _client.RetrieveAsync(pageId);
3358

34-
Assert.Equal("https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c", page.Url);
59+
page.Url.Should().Be("https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c");
60+
3561
}
3662
}
3763
}

0 commit comments

Comments
 (0)