# test.build/core/converters/base.converter.test.ts

> 18 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-converters-base-converter-test-ts
Source text: https://banes-lab.com/source/testing/test.build/core/converters/base.converter.test.ts.txt

Listed in [test.build/core/converters](https://banes-lab.com/api/source/testing/test.build/core/converters.md), after [test.build/core/converters/architecture.index.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/architecture.index.converter.test.ts.md) and before [test.build/core/converters/baseline.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/baseline.converter.test.ts.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { groupedBy, orNull } from "@banes-lab/build-scripts/core/converters/base.converter.ts";

describe("groupedBy", () => {
    it("groups items by key, keeps each group's order and sorts the groups by key", () => {
        const groups = groupedBy(["banana", "apple", "blueberry", "avocado"], (word) => word.charAt(0));
        expect([...groups.entries()]).toStrictEqual([
            ["a", ["apple", "avocado"]],
            ["b", ["banana", "blueberry"]],
        ]);
    });
});

describe("orNull", () => {
    it("keeps a text and turns a missing or empty one into null", () => {
        expect(orNull("x")).toBe("x");
        expect(orNull("")).toBeNull();
        expect(orNull()).toBeNull();
    });
});
```
