Skip to content

Commit

Permalink
Fix notification message when exactly 1 not found
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcginnes committed Feb 13, 2025
1 parent 5aa6167 commit 983d154
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,36 @@ describe("createCompletionNotification", () => {
);
});

it("should create a completion notification when exactly 1 node was not found", () => {
const fetchResult = createRandomFetchEntityDetailsResult();
fetchResult.counts.notFound.vertices = 1;
fetchResult.counts.notFound.edges = 0;
fetchResult.counts.notFound.total =
fetchResult.counts.notFound.vertices + fetchResult.counts.notFound.edges;

const notification = createCompletionNotification(fetchResult);

expect(notification.type).toBe("info");
expect(notification.message).toBe(
`Finished loading the graph, but 1 node was not found.`
);
});

it("should create a completion notification when exactly 1 edge was not found", () => {
const fetchResult = createRandomFetchEntityDetailsResult();
fetchResult.counts.notFound.vertices = 0;
fetchResult.counts.notFound.edges = 1;
fetchResult.counts.notFound.total =
fetchResult.counts.notFound.vertices + fetchResult.counts.notFound.edges;

const notification = createCompletionNotification(fetchResult);

expect(notification.type).toBe("info");
expect(notification.message).toBe(
`Finished loading the graph, but 1 edge was not found.`
);
});

it("should create a completion notification when all nodes and edges were not found", () => {
const fetchResult = createRandomFetchEntityDetailsResult();
fetchResult.entities.vertices = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ export function createCompletionNotification(
result.counts.notFound.vertices,
result.counts.notFound.edges
);
const verb = result.counts.notFound.total > 1 ? "were" : "was";
return {
message: `Finished loading the graph, but ${errorMessage} were not found.`,
message: `Finished loading the graph, but ${errorMessage} ${verb} not found.`,
type: "info",
};
}
Expand Down

0 comments on commit 983d154

Please sign in to comment.