mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 01:38:26 +02:00
Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,107 +1,107 @@
|
||||
import { describe, expect, test } from 'vite-plus/test';
|
||||
import { convert } from '../src';
|
||||
import { describe, expect, test } from "vite-plus/test";
|
||||
import { convert } from "../src";
|
||||
|
||||
describe('exporter-curl', () => {
|
||||
test('Simple example', async () => {
|
||||
describe("exporter-curl", () => {
|
||||
test("Simple example", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
url: "https://yaak.app",
|
||||
},
|
||||
[],
|
||||
),
|
||||
).toEqual(['grpcurl yaak.app'].join(' \\\n '));
|
||||
).toEqual(["grpcurl yaak.app"].join(" \\\n "));
|
||||
});
|
||||
test('Basic metadata', async () => {
|
||||
test("Basic metadata", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
url: "https://yaak.app",
|
||||
metadata: [
|
||||
{ name: 'aaa', value: 'AAA' },
|
||||
{ enabled: true, name: 'bbb', value: 'BBB' },
|
||||
{ enabled: false, name: 'disabled', value: 'ddd' },
|
||||
{ name: "aaa", value: "AAA" },
|
||||
{ enabled: true, name: "bbb", value: "BBB" },
|
||||
{ enabled: false, name: "disabled", value: "ddd" },
|
||||
],
|
||||
},
|
||||
[],
|
||||
),
|
||||
).toEqual([`grpcurl -H 'aaa: AAA'`, `-H 'bbb: BBB'`, 'yaak.app'].join(' \\\n '));
|
||||
).toEqual([`grpcurl -H 'aaa: AAA'`, `-H 'bbb: BBB'`, "yaak.app"].join(" \\\n "));
|
||||
});
|
||||
test('Basic auth', async () => {
|
||||
test("Basic auth", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
authenticationType: 'basic',
|
||||
url: "https://yaak.app",
|
||||
authenticationType: "basic",
|
||||
authentication: {
|
||||
username: 'user',
|
||||
password: 'pass',
|
||||
username: "user",
|
||||
password: "pass",
|
||||
},
|
||||
},
|
||||
[],
|
||||
),
|
||||
).toEqual([`grpcurl -H 'Authorization: Basic dXNlcjpwYXNz'`, 'yaak.app'].join(' \\\n '));
|
||||
).toEqual([`grpcurl -H 'Authorization: Basic dXNlcjpwYXNz'`, "yaak.app"].join(" \\\n "));
|
||||
});
|
||||
|
||||
test('API key auth', async () => {
|
||||
test("API key auth", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
authenticationType: 'apikey',
|
||||
url: "https://yaak.app",
|
||||
authenticationType: "apikey",
|
||||
authentication: {
|
||||
key: 'X-Token',
|
||||
value: 'tok',
|
||||
key: "X-Token",
|
||||
value: "tok",
|
||||
},
|
||||
},
|
||||
[],
|
||||
),
|
||||
).toEqual([`grpcurl -H 'X-Token: tok'`, 'yaak.app'].join(' \\\n '));
|
||||
).toEqual([`grpcurl -H 'X-Token: tok'`, "yaak.app"].join(" \\\n "));
|
||||
});
|
||||
|
||||
test('API key auth', async () => {
|
||||
test("API key auth", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
authenticationType: 'apikey',
|
||||
url: "https://yaak.app",
|
||||
authenticationType: "apikey",
|
||||
authentication: {
|
||||
location: 'query',
|
||||
key: 'token',
|
||||
value: 'tok 1',
|
||||
location: "query",
|
||||
key: "token",
|
||||
value: "tok 1",
|
||||
},
|
||||
},
|
||||
[],
|
||||
),
|
||||
).toEqual(['grpcurl', 'yaak.app?token=tok%201'].join(' \\\n '));
|
||||
).toEqual(["grpcurl", "yaak.app?token=tok%201"].join(" \\\n "));
|
||||
});
|
||||
|
||||
test('Single proto file', async () => {
|
||||
expect(await convert({ url: 'https://yaak.app' }, ['/foo/bar/baz.proto'])).toEqual(
|
||||
test("Single proto file", async () => {
|
||||
expect(await convert({ url: "https://yaak.app" }, ["/foo/bar/baz.proto"])).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/foo/bar'`,
|
||||
`-import-path '/foo'`,
|
||||
`-proto '/foo/bar/baz.proto'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Multiple proto files, same dir', async () => {
|
||||
test("Multiple proto files, same dir", async () => {
|
||||
expect(
|
||||
await convert({ url: 'https://yaak.app' }, ['/foo/bar/aaa.proto', '/foo/bar/bbb.proto']),
|
||||
await convert({ url: "https://yaak.app" }, ["/foo/bar/aaa.proto", "/foo/bar/bbb.proto"]),
|
||||
).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/foo/bar'`,
|
||||
`-import-path '/foo'`,
|
||||
`-proto '/foo/bar/aaa.proto'`,
|
||||
`-proto '/foo/bar/bbb.proto'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Multiple proto files, different dir', async () => {
|
||||
test("Multiple proto files, different dir", async () => {
|
||||
expect(
|
||||
await convert({ url: 'https://yaak.app' }, ['/aaa/bbb/ccc.proto', '/xxx/yyy/zzz.proto']),
|
||||
await convert({ url: "https://yaak.app" }, ["/aaa/bbb/ccc.proto", "/xxx/yyy/zzz.proto"]),
|
||||
).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/aaa/bbb'`,
|
||||
@@ -110,23 +110,23 @@ describe('exporter-curl', () => {
|
||||
`-import-path '/xxx'`,
|
||||
`-proto '/aaa/bbb/ccc.proto'`,
|
||||
`-proto '/xxx/yyy/zzz.proto'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Single include dir', async () => {
|
||||
expect(await convert({ url: 'https://yaak.app' }, ['/aaa/bbb'])).toEqual(
|
||||
[`grpcurl -import-path '/aaa/bbb'`, 'yaak.app'].join(' \\\n '),
|
||||
test("Single include dir", async () => {
|
||||
expect(await convert({ url: "https://yaak.app" }, ["/aaa/bbb"])).toEqual(
|
||||
[`grpcurl -import-path '/aaa/bbb'`, "yaak.app"].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Multiple include dir', async () => {
|
||||
expect(await convert({ url: 'https://yaak.app' }, ['/aaa/bbb', '/xxx/yyy'])).toEqual(
|
||||
[`grpcurl -import-path '/aaa/bbb'`, `-import-path '/xxx/yyy'`, 'yaak.app'].join(' \\\n '),
|
||||
test("Multiple include dir", async () => {
|
||||
expect(await convert({ url: "https://yaak.app" }, ["/aaa/bbb", "/xxx/yyy"])).toEqual(
|
||||
[`grpcurl -import-path '/aaa/bbb'`, `-import-path '/xxx/yyy'`, "yaak.app"].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Mixed proto and dirs', async () => {
|
||||
test("Mixed proto and dirs", async () => {
|
||||
expect(
|
||||
await convert({ url: 'https://yaak.app' }, ['/aaa/bbb', '/xxx/yyy', '/foo/bar.proto']),
|
||||
await convert({ url: "https://yaak.app" }, ["/aaa/bbb", "/xxx/yyy", "/foo/bar.proto"]),
|
||||
).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/aaa/bbb'`,
|
||||
@@ -134,45 +134,45 @@ describe('exporter-curl', () => {
|
||||
`-import-path '/foo'`,
|
||||
`-import-path '/'`,
|
||||
`-proto '/foo/bar.proto'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
test('Sends data', async () => {
|
||||
test("Sends data", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
message: JSON.stringify({ foo: 'bar', baz: 1.0 }, null, 2),
|
||||
url: "https://yaak.app",
|
||||
message: JSON.stringify({ foo: "bar", baz: 1.0 }, null, 2),
|
||||
},
|
||||
['/foo.proto'],
|
||||
["/foo.proto"],
|
||||
),
|
||||
).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/'`,
|
||||
`-proto '/foo.proto'`,
|
||||
`-d '{\n "foo": "bar",\n "baz": 1\n}'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
|
||||
test('Sends data with unresolved template tags', async () => {
|
||||
test("Sends data with unresolved template tags", async () => {
|
||||
expect(
|
||||
await convert(
|
||||
{
|
||||
url: 'https://yaak.app',
|
||||
url: "https://yaak.app",
|
||||
message: '{"timestamp": ${[ faker "timestamp" ]}, "foo": "bar"}',
|
||||
},
|
||||
['/foo.proto'],
|
||||
["/foo.proto"],
|
||||
),
|
||||
).toEqual(
|
||||
[
|
||||
`grpcurl -import-path '/'`,
|
||||
`-proto '/foo.proto'`,
|
||||
`-d '{"timestamp": \${[ faker "timestamp" ]}, "foo": "bar"}'`,
|
||||
'yaak.app',
|
||||
].join(' \\\n '),
|
||||
"yaak.app",
|
||||
].join(" \\\n "),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user