Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 9, 2024
1 parent d1db170 commit a1591c5
Show file tree
Hide file tree
Showing 10 changed files with 88,339 additions and 38,836 deletions.
3,525 changes: 2,454 additions & 1,071 deletions packages/fdr-sdk/src/__test__/output/assemblyai/apiDefinitions.json

Large diffs are not rendered by default.

8,318 changes: 5,857 additions & 2,461 deletions packages/fdr-sdk/src/__test__/output/astronomer/apiDefinitions.json

Large diffs are not rendered by default.

29,772 changes: 20,424 additions & 9,348 deletions packages/fdr-sdk/src/__test__/output/humanloop/apiDefinitions.json

Large diffs are not rendered by default.

13,629 changes: 9,534 additions & 4,095 deletions packages/fdr-sdk/src/__test__/output/hume/apiDefinitions.json

Large diffs are not rendered by default.

7,821 changes: 5,382 additions & 2,439 deletions packages/fdr-sdk/src/__test__/output/octoai/apiDefinitions.json

Large diffs are not rendered by default.

29,082 changes: 20,250 additions & 8,832 deletions packages/fdr-sdk/src/__test__/output/polytomic/apiDefinitions.json

Large diffs are not rendered by default.

29,209 changes: 20,411 additions & 8,798 deletions packages/fdr-sdk/src/__test__/output/primer/apiDefinitions.json

Large diffs are not rendered by default.

5,689 changes: 3,977 additions & 1,712 deletions packages/fdr-sdk/src/__test__/output/uploadcare/apiDefinitions.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions packages/fdr-sdk/src/api-definition/__test__/join.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,12 @@ describe("join", () => {
{
key: Latest.PropertyKey("global"),
valueShape: {
type: "id",
id: Latest.TypeId("type-4"),
default: undefined,
type: "alias",
value: {
type: "id",
id: Latest.TypeId("type-4"),
default: undefined,
},
},
description: undefined,
availability: undefined,
Expand Down
121 changes: 44 additions & 77 deletions packages/fdr-sdk/src/api-definition/__test__/unwrap.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { PropertyKey, TypeDefinition, TypeId, TypeReference } from "../latest";
import { PropertyKey, TypeDefinition, TypeId, TypeReference, TypeShape } from "../latest";
import { TypeShapeOrReference } from "../types";
import { unwrapObjectType, unwrapReference } from "../unwrap";

const PRIMITIVE_SHAPE: TypeShapeOrReference = {
type: "primitive" as const,
const PRIMITIVE_SHAPE: TypeShape = {
type: "alias",
value: {
type: "string",
regex: undefined,
minLength: undefined,
maxLength: undefined,
default: undefined,
type: "primitive" as const,
value: {
type: "string",
regex: undefined,
minLength: undefined,
maxLength: undefined,
default: undefined,
},
},
};

describe("unwrapReference", () => {
it("should noop for a non-reference", () => {
expect(unwrapReference(PRIMITIVE_SHAPE, {})).toStrictEqual({
shape: PRIMITIVE_SHAPE,
expect(unwrapReference(PRIMITIVE_SHAPE["value"], {})).toStrictEqual({
shape: PRIMITIVE_SHAPE["value"],
availability: undefined,
descriptions: [],
isOptional: false,
Expand All @@ -33,13 +36,13 @@ describe("unwrapReference", () => {
const types: Record<TypeId, TypeDefinition> = {
[TypeId("foo")]: {
name: "foo",
shape: { type: "alias", value: PRIMITIVE_SHAPE },
shape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
};
expect(unwrapReference(shape, types)).toStrictEqual({
shape: PRIMITIVE_SHAPE,
shape: PRIMITIVE_SHAPE["value"],
availability: undefined,
descriptions: [],
isOptional: false,
Expand Down Expand Up @@ -78,10 +81,7 @@ describe("unwrapReference", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
Expand All @@ -90,7 +90,7 @@ describe("unwrapReference", () => {
},
};
expect(unwrapReference(shape, types)).toStrictEqual({
shape: PRIMITIVE_SHAPE,
shape: PRIMITIVE_SHAPE["value"],
availability: undefined,
descriptions: [],
isOptional: true,
Expand All @@ -111,10 +111,7 @@ describe("unwrapReference", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: "testing-a",
},
},
Expand Down Expand Up @@ -145,10 +142,7 @@ describe("unwrapReference", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: "testing-a", // this should be ignored
},
},
Expand Down Expand Up @@ -210,13 +204,13 @@ describe("unwrapReference", () => {
},
[TypeId("c")]: {
name: "c",
shape: { type: "alias", value: PRIMITIVE_SHAPE },
shape: PRIMITIVE_SHAPE,
description: "c",
availability: "InDevelopment",
},
};
const unwrapped = unwrapReference(shape, types);
expect(unwrapped.shape).toStrictEqual(PRIMITIVE_SHAPE);
expect(unwrapped.shape).toStrictEqual(PRIMITIVE_SHAPE["value"]);
expect(unwrapped.availability).toBe("Deprecated");
expect(unwrapped.descriptions).toStrictEqual(["a", "b", "c"]);
expect(unwrapped.isOptional).toBe(true);
Expand Down Expand Up @@ -279,10 +273,7 @@ describe("unwrapObjectType", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
Expand All @@ -295,10 +286,7 @@ describe("unwrapObjectType", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
Expand All @@ -307,19 +295,13 @@ describe("unwrapObjectType", () => {
},
{
key: PropertyKey("c"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
{
key: PropertyKey("b"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand All @@ -342,10 +324,7 @@ describe("unwrapObjectType", () => {
properties: [
{
key: PropertyKey("a"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand All @@ -355,10 +334,7 @@ describe("unwrapObjectType", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
Expand All @@ -377,10 +353,7 @@ describe("unwrapObjectType", () => {
properties: [
{
key: PropertyKey("b"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand All @@ -398,10 +371,7 @@ describe("unwrapObjectType", () => {
properties: [
{
key: PropertyKey("c"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand All @@ -427,10 +397,7 @@ describe("unwrapObjectType", () => {
properties: [
{
key: PropertyKey("a"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand Down Expand Up @@ -470,10 +437,7 @@ describe("unwrapObjectType", () => {
type: "alias",
value: {
type: "optional",
shape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
Expand All @@ -482,10 +446,7 @@ describe("unwrapObjectType", () => {
},
{
key: PropertyKey("c"),
valueShape: {
type: "alias",
value: PRIMITIVE_SHAPE,
},
valueShape: PRIMITIVE_SHAPE,
description: undefined,
availability: undefined,
},
Expand All @@ -509,9 +470,12 @@ describe("unwrapObjectType", () => {
{
key: PropertyKey("c"),
valueShape: {
type: "optional",
shape: PRIMITIVE_SHAPE,
default: undefined,
type: "alias",
value: {
type: "optional",
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
description: undefined,
// availability is the least stable of the extended object
Expand All @@ -520,9 +484,12 @@ describe("unwrapObjectType", () => {
{
key: PropertyKey("b"),
valueShape: {
type: "optional",
shape: PRIMITIVE_SHAPE,
default: undefined,
type: "alias",
value: {
type: "optional",
shape: PRIMITIVE_SHAPE,
default: undefined,
},
},
description: undefined,
// availability is the least stable of the extended object
Expand Down

0 comments on commit a1591c5

Please sign in to comment.