Download src/infra/cli-root-options.test.ts from Darochin/openskynet: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/Darochin/openskynet/resolve/main/src/infra/cli-root-options.test.ts
- Command line
-
hf download hf://Darochin/openskynet/src/infra/cli-root-options.test.ts
-
curl -L -o cli-root-options.test.ts https://huggingface.co/Darochin/openskynet/resolve/main/src/infra/cli-root-options.test.ts
1.5 kB
| import { describe, expect, it } from "vitest"; | |
| import { consumeRootOptionToken, isValueToken } from "./cli-root-options.js"; | |
| describe("isValueToken", () => { | |
| it.each([ | |
| { value: "work", expected: true }, | |
| { value: "-1", expected: true }, | |
| { value: "-1.5", expected: true }, | |
| { value: "-0.5", expected: true }, | |
| { value: "--", expected: false }, | |
| { value: "--dev", expected: false }, | |
| { value: "-", expected: false }, | |
| { value: "", expected: false }, | |
| { value: undefined, expected: false }, | |
| ])("classifies %j", ({ value, expected }) => { | |
| expect(isValueToken(value)).toBe(expected); | |
| }); | |
| }); | |
| describe("consumeRootOptionToken", () => { | |
| it.each([ | |
| { args: ["--dev"], index: 0, expected: 1 }, | |
| { args: ["--profile=work"], index: 0, expected: 1 }, | |
| { args: ["--log-level=debug"], index: 0, expected: 1 }, | |
| { args: ["--profile", "work"], index: 0, expected: 2 }, | |
| { args: ["--profile", "-1"], index: 0, expected: 2 }, | |
| { args: ["--log-level", "-1.5"], index: 0, expected: 2 }, | |
| { args: ["--profile", "--no-color"], index: 0, expected: 1 }, | |
| { args: ["--profile", "--"], index: 0, expected: 1 }, | |
| { args: ["x", "--profile", "work"], index: 1, expected: 2 }, | |
| { args: ["--log-level", ""], index: 0, expected: 1 }, | |
| { args: ["--unknown"], index: 0, expected: 0 }, | |
| { args: [], index: 0, expected: 0 }, | |
| ])("consumes %j at %d", ({ args, index, expected }) => { | |
| expect(consumeRootOptionToken(args, index)).toBe(expected); | |
| }); | |
| }); | |