Skip to content

Add unit tests for Context class#10

Merged
pmcelhaney merged 2 commits into
mainfrom
copilot/create-unit-tests-for-context
Apr 8, 2026
Merged

Add unit tests for Context class#10
pmcelhaney merged 2 commits into
mainfrom
copilot/create-unit-tests-for-context

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

The Context class had no test coverage. This adds a full unit test suite using Node's built-in node:test framework (no new dependencies required — Node 24's native TypeScript stripping handles .ts files directly).

Changes

  • test/context.test.ts — 45 tests across 16 describe suites covering every public method:

    • Initial state (default pets, users, orders)
    • Pet CRUD: addPet, updatePet, getPetById, deletePet, findPetsByStatus, findPetsByTags
    • User CRUD: addUser, getUserByUsername, updateUser, deleteUser
    • Order CRUD: placeOrder, getOrderById, deleteOrder
    • getInventory — including mutation reflection
  • package.json — replaces the "No tests yet" placeholder with node --test test/**/*.test.ts

Example

describe("addPet", () => {
  it("assigns a new id to the added pet", () => {
    const pet = context.addPet({ name: "Rex", photoUrls: [] });
    assert.ok(typeof pet.id === "number");
  });

  it("increments the id for each new pet", () => {
    const first = context.addPet({ name: "Rex", photoUrls: [] });
    const second = context.addPet({ name: "Fido", photoUrls: [] });
    assert.equal(second.id, (first.id as number) + 1);
  });
});

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
@pmcelhaney pmcelhaney marked this pull request as ready for review April 8, 2026 07:47
@pmcelhaney pmcelhaney enabled auto-merge April 8, 2026 07:48
@pmcelhaney pmcelhaney added this pull request to the merge queue Apr 8, 2026
Copilot AI changed the title [WIP] Add unit tests for context class Add unit tests for Context class Apr 8, 2026
Copilot AI requested a review from pmcelhaney April 8, 2026 07:49
Merged via the queue into main with commit 995869a Apr 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create unit tests for context

2 participants