From 7fe4d66f448534a6c39be77c7e6ee07e22724404 Mon Sep 17 00:00:00 2001 From: thejan77 Date: Fri, 14 Mar 2025 05:14:28 +0530 Subject: [PATCH 1/2] Implement emoji picker for goals using emoji-mart --- src/api/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/types.ts b/src/api/types.ts index f75edad..e42daae 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -27,6 +27,7 @@ export interface Goal { accountId: string transactionIds: string[] tagIds: string[] + icon: "🚗" } export interface Tag { From a278b5b6db85ffc7081c38cde168b0991a6e5151 Mon Sep 17 00:00:00 2001 From: thejan77 Date: Sat, 22 Mar 2025 02:11:37 +0530 Subject: [PATCH 2/2] Added unit test for GetGoalsForUser route --- src/ui/GoalControllerTests.cs | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/ui/GoalControllerTests.cs diff --git a/src/ui/GoalControllerTests.cs b/src/ui/GoalControllerTests.cs new file mode 100644 index 0000000..a5922d9 --- /dev/null +++ b/src/ui/GoalControllerTests.cs @@ -0,0 +1,48 @@ +using Xunit; +using Moq; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using YourNamespace.Controllers; // Replace with actual namespace +using YourNamespace.Models; +using YourNamespace.Services; // Services being tested + +public class GoalControllerTests +{ + private readonly FakeCollections collections; + + public GoalControllerTests() + { + collections = new FakeCollections(); // Mock data collection + } + + [Fact] + public async Task GetForUser_ReturnsGoalsForUser() + { + // Arrange + var goals = collections.GetGoals(); // Mock goals list + var users = collections.GetUsers(); // Mock users list + + var goalsService = new FakeGoalsService(goals, goals[0]); // Inject fake service + var usersService = new FakeUsersService(users, users[0]); + + var controller = new GoalController(goalsService, usersService); + + // Simulate HTTP context (needed for controller actions) + var httpContext = new DefaultHttpContext(); + controller.ControllerContext.HttpContext = httpContext; + + // Act: Call the controller method with a userId + var result = await controller.GetForUser(goals[0].UserId!); + + // Assert: Check the response is not null + Assert.NotNull(result); + + // Assert: Validate each goal in the response + foreach (Goal goal in result!) + { + Assert.IsAssignableFrom(goal); // Check type + Assert.Equal(goals[0].UserId, goal.UserId); // Check correct userId + } + } +}