Sign In

@buzzr/dfs-testkit

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@buzzr/dfs-testkit - npm Package Compare versions

Comparing version
4.0.0
to
5.0.0
+28
-2
package.json
{
"name": "@buzzr/dfs-testkit",
"version": "4.0.0",
"version": "5.0.0",
"description": "Fixture builders and mock providers for @buzzr/dfs-engine consumers.",
"license": "MIT",
"author": "Sarvesh Chidambaram",
"repository": {
"type": "git",
"url": "git+https://github.com/Buzzr-app/dfs-engine.git",
"directory": "packages/dfs-testkit"
},
"homepage": "https://github.com/Buzzr-app/dfs-engine/tree/main/packages/dfs-testkit#readme",
"bugs": {
"url": "https://github.com/Buzzr-app/dfs-engine/issues"
},
"type": "module",

@@ -31,4 +40,21 @@ "main": "./dist/index.cjs",

},
"keywords": [
"dfs",
"daily-fantasy-sports",
"testing",
"fixtures",
"mocks",
"test-fixtures",
"fixture-builders",
"vitest",
"jest",
"settlement",
"grading",
"prizepicks",
"underdog",
"typescript",
"buzzr"
],
"dependencies": {
"@buzzr/dfs-engine": "^4.0.0"
"@buzzr/dfs-engine": "^5.0.0"
},

@@ -35,0 +61,0 @@ "engines": {

# @buzzr/dfs-testkit
Fixture builders and mock providers for `@buzzr/dfs-engine` tests.
[![npm version](https://img.shields.io/npm/v/@buzzr/dfs-testkit)](https://www.npmjs.com/package/@buzzr/dfs-testkit)
[![npm downloads](https://img.shields.io/npm/dm/@buzzr/dfs-testkit)](https://www.npmjs.com/package/@buzzr/dfs-testkit)
[![CI](https://github.com/Buzzr-app/dfs-engine/actions/workflows/ci.yml/badge.svg)](https://github.com/Buzzr-app/dfs-engine/actions/workflows/ci.yml)
[![types](https://img.shields.io/npm/types/@buzzr/dfs-testkit)](https://www.npmjs.com/package/@buzzr/dfs-testkit)
[![license](https://img.shields.io/npm/l/@buzzr/dfs-testkit)](https://github.com/Buzzr-app/dfs-engine/blob/main/LICENSE)
Fixtures emit v4-canonical DFS entries (`actual`, `status`,
`actualsByLegId`) and include `makeInvalidDfsEntry` for consumer validation
tests.
**Fixture builders and mock stat providers for testing [`@buzzr/dfs-engine`](https://www.npmjs.com/package/@buzzr/dfs-engine) integrations.** Build a valid v4-canonical DFS entry in one line, override only what your test cares about, and wire a deterministic stat provider without touching the network.
## Install
```bash
npm install --save-dev @buzzr/dfs-testkit @buzzr/dfs-engine
```
## 30-second quick start
Works with Vitest, Jest, or any test runner:
```ts
import { test, expect } from 'vitest';
import { createDfsEngine } from '@buzzr/dfs-engine';
import {
makeDfsEntry,
makeDfsLeg,
makeGameLogEntry,
createMockStatProvider,
} from '@buzzr/dfs-testkit';
test('a PrizePicks Power entry settles as won when both legs hit', async () => {
const entry = makeDfsEntry({
legs: [
makeDfsLeg({ legId: 'leg-1', propType: 'Points', line: 20.5 }),
makeDfsLeg({ legId: 'leg-2', propType: 'Rebounds', line: 6.5 }),
],
});
const provider = createMockStatProvider({
'leg-1': [makeGameLogEntry({ points: '24' })],
'leg-2': [makeGameLogEntry({ rebounds: '9' })],
});
const engine = createDfsEngine({ statProviders: [provider] });
const result = await engine.settleEntry(entry, { statProviderId: provider.id });
expect(result.status).toBe('won');
});
```
Every builder returns a complete, engine-valid object with sensible defaults (`prizepicks` / `power` / NBA points over), so tests only spell out what they assert.
## API
| Export | Purpose |
| -------------------------- | ---------------------------------------------------------------------------- |
| `makeDfsEntry()` | A valid `DfsEntryInput` (PrizePicks Power, one leg) with overridable fields |
| `makeDfsLeg()` | A valid `DfsLegInput` (NBA Points over 20.5) with overridable fields |
| `makeGameLogEntry()` | A valid `PlayerGameLogEntryShape` boxscore row with overridable stats |
| `createMockStatProvider()` | A deterministic `StatProvider` serving rows from a `legId → rows` map |
| `makeInvalidDfsEntry()` | An entry with duplicate leg ids and zero stake, for validation-path tests |
Fixtures emit v4-canonical shapes (`actual`, `status`, per-leg `legId` keys), so anything you build here passes the engine's boundary validators — except `makeInvalidDfsEntry`, which is designed to fail them.
## When to use this vs siblings
| You want to… | Reach for |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Write unit tests for your own settlement integration | **this package** |
| Prove your wiring grades identically to Buzzr's | [`@buzzr/dfs-engine-test-vectors`](https://www.npmjs.com/package/@buzzr/dfs-engine-test-vectors) |
| Grade entries in production code | [`@buzzr/dfs-engine`](https://www.npmjs.com/package/@buzzr/dfs-engine) |
| Grade entries from the command line | [`@buzzr/dfs-cli`](https://www.npmjs.com/package/@buzzr/dfs-cli) |
## Links
- [Engine API docs](https://buzzr-app.github.io/dfs-engine/)
- [Monorepo & full package family](https://github.com/Buzzr-app/dfs-engine)
- [Issues](https://github.com/Buzzr-app/dfs-engine/issues)
## License
MIT