Skip to content

Commit cb4c793

Browse files
committed
Fixed: missing test coverage for applying default page size in includes
1 parent 6deb79f commit cb4c793

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,15 @@ public async Task Uses_default_page_number_and_size()
500500

501501
Blog blog = _fakers.Blog.Generate();
502502
blog.Posts = _fakers.BlogPost.Generate(3);
503+
blog.Posts.ToList().ForEach(post => post.Labels = _fakers.Label.Generate(3).ToHashSet());
503504

504505
await _testContext.RunOnDatabaseAsync(async dbContext =>
505506
{
506507
dbContext.Blogs.Add(blog);
507508
await dbContext.SaveChangesAsync();
508509
});
509510

510-
string route = $"/blogs/{blog.StringId}/posts";
511+
string route = $"/blogs/{blog.StringId}/posts?include=labels";
511512

512513
// Act
513514
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
@@ -519,10 +520,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
519520
responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId);
520521
responseDocument.Data.ManyValue[1].Id.Should().Be(blog.Posts[1].StringId);
521522

523+
responseDocument.Included.ShouldHaveCount(4);
524+
522525
responseDocument.Links.ShouldNotBeNull();
523526
responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}");
524527
responseDocument.Links.First.Should().Be(responseDocument.Links.Self);
525-
responseDocument.Links.Last.Should().Be($"{HostPrefix}{route}?page%5Bnumber%5D=2");
528+
responseDocument.Links.Last.Should().Be($"{responseDocument.Links.Self}&page%5Bnumber%5D=2");
526529
responseDocument.Links.Prev.Should().BeNull();
527530
responseDocument.Links.Next.Should().Be(responseDocument.Links.Last);
528531
}

0 commit comments

Comments
 (0)