@@ -10,15 +10,21 @@ namespace Notion.IntegrationTests
1010{
1111 public class IBlocksClientTests
1212 {
13- [ Fact ]
14- public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks ( )
13+ private readonly INotionClient _client ;
14+
15+ public IBlocksClientTests ( )
1516 {
1617 var options = new ClientOptions
1718 {
1819 AuthToken = Environment . GetEnvironmentVariable ( "NOTION_AUTH_TOKEN" )
1920 } ;
20- INotionClient _client = NotionClientFactory . Create ( options ) ;
2121
22+ _client = NotionClientFactory . Create ( options ) ;
23+ }
24+
25+ [ Fact ]
26+ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks ( )
27+ {
2228 var pageId = "3c357473a28149a488c010d2b245a589" ;
2329
2430 var page = await _client . Pages . CreateAsync (
@@ -47,12 +53,27 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks()
4753 new TableOfContentsBlock
4854 {
4955 TableOfContents = new TableOfContentsBlock . Data ( )
56+ } ,
57+ new CalloutBlock
58+ {
59+ Callout = new CalloutBlock . Info
60+ {
61+ Text = new List < RichTextBaseInput > {
62+ new RichTextTextInput
63+ {
64+ Text = new Text
65+ {
66+ Content = "Test"
67+ }
68+ }
69+ }
70+ }
5071 }
5172 }
5273 }
5374 ) ;
5475
55- blocks . Results . Should ( ) . HaveCount ( 3 ) ;
76+ blocks . Results . Should ( ) . HaveCount ( 4 ) ;
5677
5778 // cleanup
5879 await _client . Pages . UpdateAsync ( page . Id , new PagesUpdateParameters
@@ -64,12 +85,6 @@ public async Task AppendChildrenAsync_AppendsBlocksGivenBlocks()
6485 [ Fact ]
6586 public async Task UpdateBlockAsync_UpdatesGivenBlock ( )
6687 {
67- var options = new ClientOptions
68- {
69- AuthToken = Environment . GetEnvironmentVariable ( "NOTION_AUTH_TOKEN" )
70- } ;
71- INotionClient _client = NotionClientFactory . Create ( options ) ;
72-
7388 var pageId = "3c357473a28149a488c010d2b245a589" ;
7489
7590 var page = await _client . Pages . CreateAsync (
@@ -111,12 +126,6 @@ public async Task UpdateBlockAsync_UpdatesGivenBlock()
111126 [ Fact ]
112127 public async Task DeleteAsync_DeleteBlockWithGivenId ( )
113128 {
114- var options = new ClientOptions
115- {
116- AuthToken = Environment . GetEnvironmentVariable ( "NOTION_AUTH_TOKEN" )
117- } ;
118- INotionClient _client = NotionClientFactory . Create ( options ) ;
119-
120129 var pageId = "3c357473a28149a488c010d2b245a589" ;
121130
122131 var page = await _client . Pages . CreateAsync (
@@ -159,12 +168,6 @@ public async Task DeleteAsync_DeleteBlockWithGivenId()
159168 [ MemberData ( nameof ( BlockData ) ) ]
160169 public async Task UpdateAsync_UpdatesGivenBlock ( Block block , IUpdateBlock updateBlock , Action < Block > assert )
161170 {
162- var options = new ClientOptions
163- {
164- AuthToken = Environment . GetEnvironmentVariable ( "NOTION_AUTH_TOKEN" )
165- } ;
166- INotionClient _client = NotionClientFactory . Create ( options ) ;
167-
168171 var pageParentId = "3c357473a28149a488c010d2b245a589" ;
169172
170173 var page = await _client . Pages . CreateAsync (
@@ -311,6 +314,48 @@ private static IEnumerable<object[]> BlockData()
311314 Assert . NotNull ( block ) ;
312315 Assert . IsType < TableOfContentsBlock > ( block ) ;
313316 } )
317+ } ,
318+ new object [ ]
319+ {
320+ new CalloutBlock
321+ {
322+ Callout = new CalloutBlock . Info
323+ {
324+ Text = new List < RichTextBaseInput >
325+ {
326+ new RichTextTextInput
327+ {
328+ Text = new Text
329+ {
330+ Content = "Test"
331+ }
332+ }
333+ }
334+ }
335+ } ,
336+ new CalloutUpdateBlock ( )
337+ {
338+ Callout = new CalloutUpdateBlock . Info
339+ {
340+ Text = new List < RichTextBaseInput >
341+ {
342+ new RichTextTextInput
343+ {
344+ Text = new Text
345+ {
346+ Content = "Test 2"
347+ }
348+ }
349+ }
350+ }
351+ } ,
352+ new Action < Block > ( ( block ) =>
353+ {
354+ Assert . NotNull ( block ) ;
355+ var calloutBlock = Assert . IsType < CalloutBlock > ( block ) ;
356+
357+ Assert . Equal ( "Test 2" , calloutBlock . Callout . Text . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
358+ } )
314359 }
315360 } ;
316361 }
0 commit comments