# test.scripts/core/analyzers/rate.analyzer.test.ts

> 25 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-scripts-core-analyzers-rate-analyzer-test-ts
Source text: https://banes-lab.com/source/testing/test.scripts/core/analyzers/rate.analyzer.test.ts.txt

Listed in [test.scripts/core/analyzers](https://banes-lab.com/api/source/testing/test.scripts/core/analyzers.md), after [test.scripts/core/analyzers/export.analyzer.test.ts](https://banes-lab.com/source/testing/test.scripts/core/analyzers/export.analyzer.test.ts.md) and before [test.scripts/core/analyzers/rate.fixture.ts](https://banes-lab.com/source/testing/test.scripts/core/analyzers/rate.fixture.ts.md).

## Contained in

- [test.scripts/core/analyzers](https://banes-lab.com/anatomy/testing/folder-testing-test-scripts-core-analyzers.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import { summarize, withinMonths } from "@project/scripts/core/analyzers/rate.analyzer.ts";
import { ARCHITECTS_GROUP } from "@project/scripts/configuration/strings/rate.strings.ts";
import { PAGE } from "./rate.fixture.ts";
import { PEER_GROUPS } from "@project/scripts/configuration/constants/rate.constants.ts";
import { recordsIn } from "@project/scripts/core/selectors/rate.selector.ts";

const ARCHITECTS = PEER_GROUPS.find((group) => group.label === ARCHITECTS_GROUP);
const EVERY = PEER_GROUPS.find((group) => group.titles.length === 0);

describe("withinMonths and summarize", () => {
    it("keeps the records from the window before the newest one", () => {
        expect(withinMonths(recordsIn(PAGE), 24).map((record) => record.id)).toStrictEqual(["a", "b", "c"]);
    });

    it("summarizes a group by title and seniority and places a rate in it", () => {
        if (ARCHITECTS === undefined || EVERY === undefined) {
            throw new Error("the peer groups changed");
        }
        const records = recordsIn(PAGE);
        const architects = summarize(records, ARCHITECTS, 800);
        expect([architects.count, architects.median, architects.highest, architects.below]).toStrictEqual([
            3, 700, 900, 67,
        ]);
        expect(summarize(records, EVERY, null).count).toBe(4);
        expect(summarize([], EVERY, 800)).toMatchObject({ below: null, count: 0 });
    });
});
```
