Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CommBank-Web
Submodule CommBank-Web added at 73f96c
2 changes: 1 addition & 1 deletion codelabs/1_backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ using MongoDB.Driver;

namespace CommBank.Services;

public class GoalsService : IGoalsService
public sService : IGoalsService
{
private readonly IMongoCollection<Goal> _goalsCollection;

Expand Down
22 changes: 16 additions & 6 deletions codelabs/2_frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,22 @@ export function GoalManager(props: Props) {
const hasIcon = () => icon != null

const pickEmojiOnClick = (emoji: BaseEmoji, event: MouseEvent) => {
// TODO(stop event propogation)
// TODO(set icon locally)
// TODO(close emoji picker)
// TODO(create updated goal)
// TODO(update store)
// TODO(update database)
const pickEmojiOnClick = (emoji: BaseEmoji, event: MouseEvent) => {
event.stopPropagation()

setIcon(emoji.native)
setEmojiPickerIsOpen(false)

const updatedGoal: Goal = {
...props.goal,
icon: emoji.native ?? props.goal.icon,
name: name ?? props.goal.name,
targetDate: targetDate ?? props.goal.targetDate,
targetAmount: targetAmount ?? props.goal.targetAmount,
}

dispatch(updateGoalRedux(updatedGoal))
}
}

return (
Expand Down
27 changes: 25 additions & 2 deletions tasks/4_tests/cover_get_for_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,32 @@ public class GoalControllerTests

// ...

[Fact]
public async void GetForUser()
[Fact]
public async void GetForUser()
{
// Arrange
var goals = collections.GetGoals();
var users = collections.GetUsers();
IGoalsService goalsService = new FakeGoalsService(goals, goals[0]);
IUsersService usersService = new FakeUsersService(users, users[0]);
GoalController controller = new(goalsService, usersService);

// Act
var httpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext();
controller.ControllerContext.HttpContext = httpContext;
var result = await controller.GetForUser(goals[0].UserId!);

// Assert
Assert.NotNull(result);

var index = 0;
foreach (Goal goal in result!)
{
Assert.IsAssignableFrom<Goal>(goal);
Assert.Equal(goals[0].UserId, goal.UserId);
index++;
}
}
// Arrange
var goals = collections.GetGoals();
var users = collections.GetUsers();
Expand Down