|
1 | 1 | import { writeFileSync } from "node:fs"; |
2 | 2 | import { http, HttpResponse } from "msw"; |
| 3 | +import { endEventLoop } from "./helpers/end-event-loop"; |
3 | 4 | import { mockAccountId, mockApiToken } from "./helpers/mock-account-id"; |
4 | 5 | import { mockConsoleMethods } from "./helpers/mock-console"; |
5 | 6 | import { clearDialogs, mockConfirm } from "./helpers/mock-dialogs"; |
@@ -53,6 +54,57 @@ describe("wrangler", () => { |
53 | 54 | `); |
54 | 55 | }); |
55 | 56 |
|
| 57 | + it("should show help when no argument is passed", async () => { |
| 58 | + await runWrangler("kv"); |
| 59 | + await endEventLoop(); |
| 60 | + expect(std.out).toMatchInlineSnapshot(` |
| 61 | + "wrangler kv |
| 62 | +
|
| 63 | + 🗂️ Manage Workers KV Namespaces |
| 64 | +
|
| 65 | + COMMANDS |
| 66 | + wrangler kv namespace Interact with your Workers KV Namespaces |
| 67 | + wrangler kv key Individually manage Workers KV key-value pairs |
| 68 | + wrangler kv bulk Interact with multiple Workers KV key-value pairs at once |
| 69 | +
|
| 70 | + GLOBAL FLAGS |
| 71 | + -j, --experimental-json-config Experimental: support wrangler.json [boolean] |
| 72 | + -c, --config Path to .toml configuration file [string] |
| 73 | + -e, --env Environment to use for operations and .env files [string] |
| 74 | + -h, --help Show help [boolean] |
| 75 | + -v, --version Show version number [boolean]" |
| 76 | + `); |
| 77 | + }); |
| 78 | + |
| 79 | + it("should show help when an invalid argument is passed", async () => { |
| 80 | + await expect(() => runWrangler("kv asdf")).rejects.toThrow( |
| 81 | + "Unknown argument: asdf" |
| 82 | + ); |
| 83 | + expect(std.err).toMatchInlineSnapshot(` |
| 84 | + "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown argument: asdf[0m |
| 85 | +
|
| 86 | + " |
| 87 | + `); |
| 88 | + expect(std.out).toMatchInlineSnapshot(` |
| 89 | + " |
| 90 | + wrangler kv |
| 91 | +
|
| 92 | + 🗂️ Manage Workers KV Namespaces |
| 93 | +
|
| 94 | + COMMANDS |
| 95 | + wrangler kv namespace Interact with your Workers KV Namespaces |
| 96 | + wrangler kv key Individually manage Workers KV key-value pairs |
| 97 | + wrangler kv bulk Interact with multiple Workers KV key-value pairs at once |
| 98 | +
|
| 99 | + GLOBAL FLAGS |
| 100 | + -j, --experimental-json-config Experimental: support wrangler.json [boolean] |
| 101 | + -c, --config Path to .toml configuration file [string] |
| 102 | + -e, --env Environment to use for operations and .env files [string] |
| 103 | + -h, --help Show help [boolean] |
| 104 | + -v, --version Show version number [boolean]" |
| 105 | + `); |
| 106 | + }); |
| 107 | + |
56 | 108 | describe("kv namespace", () => { |
57 | 109 | describe("create", () => { |
58 | 110 | function mockCreateRequest(expectedTitle: string) { |
|
0 commit comments