Skip to content

Commit

Permalink
Fix feedback sync (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyarenei authored Nov 11, 2023
1 parent 97df66c commit edc0ef2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Jellyfin.Plugin.ListenBrainz.Api/BaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BaseClient : HttpClient
public static readonly JsonSerializerSettings SerializerSettings = new()
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Include,
ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() }
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.ObjectModel;
using Jellyfin.Plugin.ListenBrainz.Api.Models;
using Jellyfin.Plugin.ListenBrainz.Api.Models.Requests;
using Jellyfin.Plugin.ListenBrainz.Api.Resources;
using Newtonsoft.Json;
using Xunit;

Expand Down Expand Up @@ -40,3 +42,20 @@ public void Listen_EncodeAndDecode()
Assert.NotNull(deserializedListen);
}
}

public class RecordingFeedbackTests
{
[Theory]
[InlineData(FeedbackScore.Hated)]
[InlineData(FeedbackScore.Loved)]
[InlineData(FeedbackScore.Neutral)]
public void FeedbackValues_Encode(FeedbackScore score)
{
var request = new RecordingFeedbackRequest { Score = score };
var actualJson = JsonConvert.SerializeObject(request, BaseClient.SerializerSettings);
Assert.NotNull(actualJson);

var expectedJson = @"{""score"":" + (int)score + "}";
Assert.Equal(expectedJson, actualJson);
}
}

0 comments on commit edc0ef2

Please sign in to comment.