Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avermeil committed Mar 7, 2024
1 parent dc857a5 commit dea642a
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 3,491 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@types/stream-json": "^1.7.7",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"axios-mock-adapter": "^1.22.0",
"esbuild": "^0.20.1",
"eslint": "^7.14.0",
"jest": "^29.0.3",
Expand Down
39 changes: 1 addition & 38 deletions scripts/enums.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs";
import { internalEnums, VERSION, errors } from "../src/protos/index";
import { internalEnums, VERSION } from "../src/protos/index";
import { FILES } from "./path";

export async function compileEnums(): Promise<void> {
Expand All @@ -10,7 +10,6 @@ export async function compileEnums(): Promise<void> {
stream.write("\n// eslint-disable-next-line\n");
stream.write("export namespace enums {\n");

// Add all regular enums
for (const [fullName, def] of Object.entries(internalEnums)) {
const [name] = fullName.split("Enum");
const values = Object.entries(def).find(
Expand Down Expand Up @@ -38,42 +37,6 @@ export async function compileEnums(): Promise<void> {
stream.write(`\n${enumStr}\n`);
}

// Add all error enums
for (const [fullName, def] of Object.entries(errors)) {
const [name] = fullName.split("Enum");
const values = Object.entries(def).find(
([, val]) => typeof val !== "function" // Get the object field which isn't a function, which happens to be the enum values
)?.[1];
console.log(name, values);
console.log(def);

if (!values) {
console.warn("Could not find values for enum " + fullName);
continue;
}

if (!name) {
console.warn("Could not find name for enum " + fullName);
continue;
}

const pairs = Object.keys(values).map((key) => {
const protoVal = values[key];
return `${key} = ${protoVal}, // ${key}`;
});
const enumStr = `export enum ${name} {
${pairs.join("\n")}
}`;

const docsLink = buildEnumLink(VERSION, fullName, name);

stream.write(`\n/**
* @name ${fullName}.${name}
* @link ${docsLink}
*/`);
stream.write(`\n${enumStr}\n`);
}

stream.write("}\n");
stream.end();

Expand Down
Loading

0 comments on commit dea642a

Please sign in to comment.