Skip to content

Commit 64a18e6

Browse files
committed
added failing test for issue #453 (empty 'data' array for HasManyThrough)
1 parent 3ade2a7 commit 64a18e6

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/JsonApiDotNetCoreExampleTests/Acceptance/ManyToManyTests.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,34 @@ public async Task Can_Fetch_Many_To_Many_Through_GetById()
110110
Assert.Equal(tag.Name, tagResponse.Name);
111111
}
112112

113+
[Fact]
114+
public async Task Can_Fetch_Many_To_Many_Without_Include()
115+
{
116+
// arrange
117+
var context = _fixture.GetService<AppDbContext>();
118+
var article = _articleFaker.Generate();
119+
var tag = _tagFaker.Generate();
120+
var articleTag = new ArticleTag
121+
{
122+
Article = article,
123+
Tag = tag
124+
};
125+
context.ArticleTags.Add(articleTag);
126+
await context.SaveChangesAsync();
127+
128+
var route = $"/api/v1/articles/{article.Id}";
129+
130+
// act
131+
var response = await _fixture.Client.GetAsync(route);
132+
133+
// assert
134+
var body = await response.Content.ReadAsStringAsync();
135+
Assert.True(HttpStatusCode.OK == response.StatusCode, $"{route} returned {response.StatusCode} status code with payload: {body}");
136+
137+
var document = JsonConvert.DeserializeObject<Document>(body);
138+
Assert.Null(document.Data.Relationships["tags"].ManyData);
139+
}
140+
113141
[Fact]
114142
public async Task Can_Create_Many_To_Many()
115143
{
@@ -269,4 +297,4 @@ public async Task Can_Update_Many_To_Many_Through_Relationship_Link()
269297
Assert.Equal(tag.Id, persistedArticleTag.TagId);
270298
}
271299
}
272-
}
300+
}

0 commit comments

Comments
 (0)