Skip to content

Commit

Permalink
add snail + fix file test
Browse files Browse the repository at this point in the history
  • Loading branch information
thuy3nana committed Dec 23, 2024
1 parent 71125e0 commit d6a74d9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Set a default color, size, pet type, position, and theme when you open a Pet Pan

* Pet Color: black, brown, green, yellow, gray, purple, red, white, orange
* Pet Size: nano, small, medium, large
* Pet Type: cat, chicken, crab, clippy, cockatiel, dog, horse, mod, rocky, rubber duck, snake, totoro, turtle, zappy
* Pet Type: cat, chicken, crab, clippy, cockatiel, dog, horse, mod, rocky, rubber duck, snake, totoro, turtle, zappy, snail

.. image:: _static/screenshot-2.gif
:alt: Usage screenshot
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"snake",
"totoro",
"turtle",
"zappy"
"zappy",
"snail"
],
"default": "cat",
"description": "Pet type",
Expand Down
4 changes: 2 additions & 2 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ class PetWebviewContainer implements IPetPanel {
command: 'delete-pet',
name: petName,
type: petType,
color: petColor
color: petColor,
});
}

Expand Down Expand Up @@ -1000,7 +1000,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
command: 'delete-pet',
name: petName,
type: petType,
color: petColor
color: petColor,
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/panel/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,11 @@ export function petPanelApp(
});
});
case 'delete-pet':
var pet = allPets.locatePet(message.name, message.type, message.color);
var pet = allPets.locatePet(
message.name,
message.type,
message.color,
);
if (pet) {
allPets.remove(pet);
saveState(stateApi);
Expand Down
18 changes: 15 additions & 3 deletions src/panel/pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export interface IPetCollection {
reset(): void;
seekNewFriends(): string[];
locate(name: string): PetElement | undefined;
locatePet(name: string, type: string, color: string): PetElement | undefined;
locatePet(
name: string,
type: string,
color: string,
): PetElement | undefined;
remove(pet: PetElement): void;
}

Expand Down Expand Up @@ -89,9 +93,17 @@ export class PetCollection implements IPetCollection {
});
}

locatePet(name: string, type: string, color: string): PetElement | undefined {
locatePet(
name: string,
type: string,
color: string,
): PetElement | undefined {
return this._pets.find((collection) => {
return collection.pet.name === name && collection.type === type && collection.color === color;
return (
collection.pet.name === name &&
collection.type === type &&
collection.color === color
);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/panel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ suite('Pets Test Suite', () => {
collection.push(testPetElement);
assert.strictEqual(collection.locate('Jerry'), testPetElement);

collection.remove('Jerry');
collection.remove(testPetElement);
assert.strictEqual(collection.locate('Jerry'), undefined);
});

Expand Down

0 comments on commit d6a74d9

Please sign in to comment.