Skip to content

Commit

Permalink
test: add test for hardcoded string literal value
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondMofeng committed Feb 3, 2024
1 parent 3bc6e0e commit 73fbd2c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dist/screeps-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,21 @@ function resources(o: GenericStore): ResourceConstant[] {
Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000, roomName: "W1N1" });
Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 });

// Testing the hardcoded string literal value of the `type` field
{
// error
Game.market.createOrder({
// @ts-expect-error
type: "BUY",
resourceType: RESOURCE_GHODIUM,
price: 9.95,
totalAmount: 10000,
});

// okay
Game.market.createOrder({ type: "buy", resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 });
}

// Game.market.deal(orderId, amount, [yourRoomName])
Game.market.deal("57cd2b12cda69a004ae223a3", 1000, "W1N1");

Expand Down

0 comments on commit 73fbd2c

Please sign in to comment.