Skip to content

Add tests for the play-style read (tight/loose, passive/aggressive) #54

Description

@pip-robot

derivePlayStyle() in src/lib/playStyle.ts is the function behind the quadrant on /stats. It takes your lifetime tendencies and works out which of the four archetypes you are: The Shark, The Maniac, The Rock, The Station.

It is pure, it is 76 lines, and it currently has no tests. A clean first PR on real code that people actually see the output of.

The task

Add an AVA test file (tests/playStyle.test.ts) covering derivePlayStyle():

  • The four quadrants. Build a SeatStats for each corner and check you get the right key and name. The splits are in the file: looseness at 0.42, aggression at 0.5. Include a hand that lands exactly on a split, since >= decides it.
  • Divide by zero. A player with handsDealt: 0 must not produce NaN. Same for raises + calls === 0 and betsFaced === 0. Assert the actual returned numbers.
  • The ready gate. STYLE_MIN_HANDS is 20. Check ready is false below it, true at it, and that an archetype is still named either way.

emptySeatStats() in src/lib/reads.ts gives you a zeroed starting point to spread over.

Getting started

pnpm install
pnpm test          # the AVA suite

Follow the style of the existing files in tests/ (useMoney.test.ts is a short one to copy the shape from). Tests describe what the code does, so read the function and assert its real behaviour rather than what you think it should do. If you find something that looks wrong, say so in the PR rather than fixing it quietly, and we will talk about it.

Done when

pnpm test:all passes and the four quadrants, the zero cases and the ready gate are all covered.

New here? See CONTRIBUTING.md. Merged work puts your name on playpip.io/credits.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions