Skip to content

Commit

Permalink
Updated pnpm-lock.yamls and fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andresceballosm committed Jul 31, 2024
1 parent 4383192 commit abb82b7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
12 changes: 6 additions & 6 deletions packages/taco/src/conditions/base/json-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parse } from "jsonpath";
import { z } from "zod";
import { parse } from 'jsonpath';
import { z } from 'zod';

import { Condition } from "../condition";
import { OmitConditionType, returnValueTestSchema } from "../shared";
import { Condition } from '../condition';
import { OmitConditionType, returnValueTestSchema } from '../shared';

export const JsonApiConditionType = "json-api";
export const JsonApiConditionType = 'json-api';

const validateJSONPath = (jsonPath: string): boolean => {
try {
Expand All @@ -18,7 +18,7 @@ const validateJSONPath = (jsonPath: string): boolean => {
export const jsonPathSchema = z
.string()
.refine((val) => validateJSONPath(val), {
message: "Invalid JSONPath expression",
message: 'Invalid JSONPath expression',
});

export const JsonApiConditionSchema = z.object({
Expand Down
19 changes: 11 additions & 8 deletions packages/taco/test/conditions/base/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('JsonApiCondition', () => {
endpoint: 'not-a-url',
};

const result = JsonApiCondition.validate(JsonApiConditionSchema, badJsonApiObj);
const result = JsonApiCondition.validate(
JsonApiConditionSchema,
badJsonApiObj,
);

expect(result.error).toBeDefined();
expect(result.data).toBeUndefined();
Expand All @@ -35,26 +38,26 @@ describe('JsonApiCondition', () => {
},
});
});

describe('parameters', () => {
it('accepts conditions without query path', () => {
const { query, ...noQueryObj} = testJsonApiConditionObj;
const { query, ...noQueryObj } = testJsonApiConditionObj;
const result = JsonApiCondition.validate(
JsonApiConditionSchema,
noQueryObj
noQueryObj,
);

expect(result.error).toBeUndefined();
expect(result.data).toEqual(noQueryObj);
});

it('accepts conditions without parameters', () => {
const { query, ...noParamsObj} = testJsonApiConditionObj;
const { query, ...noParamsObj } = testJsonApiConditionObj;
const result = JsonApiCondition.validate(
JsonApiConditionSchema,
noParamsObj
noParamsObj,
);

expect(result.error).toBeUndefined();
expect(result.data).toEqual(noParamsObj);
});
Expand Down
11 changes: 7 additions & 4 deletions packages/taco/test/conditions/condition-expr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,20 @@ describe('condition set', () => {

it('json api condition serialization', () => {
const conditionExpr = new ConditionExpression(jsonApiCondition);

const conditionExprJson = conditionExpr.toJson();
expect(conditionExprJson).toBeDefined();
expect(conditionExprJson).toContain('endpoint');
expect(conditionExprJson).toContain('https://_this_would_totally_fail.com');
expect(conditionExprJson).toContain(
'https://_this_would_totally_fail.com',
);
expect(conditionExprJson).toContain('parameters');
expect(conditionExprJson).toContain('query');
expect(conditionExprJson).toContain('$.ethereum.usd');
expect(conditionExprJson).toContain('returnValueTest');

const conditionExprFromJson = ConditionExpression.fromJSON(conditionExprJson);

const conditionExprFromJson =
ConditionExpression.fromJSON(conditionExprJson);
expect(conditionExprFromJson).toBeDefined();
expect(conditionExprFromJson.condition).toBeInstanceOf(JsonApiCondition);
});
Expand Down
9 changes: 3 additions & 6 deletions packages/taco/test/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ import {
ContractConditionType,
FunctionAbiProps,
} from '../src/conditions/base/contract';
import {
JsonApiConditionProps,
JsonApiConditionType
} from '../src/conditions/base/json-api';
import { JsonApiConditionType } from '../src/conditions/base/json-api';
import {
RpcConditionProps,
RpcConditionType,
Expand Down Expand Up @@ -230,8 +227,8 @@ export const testJsonApiConditionObj = {
conditionType: JsonApiConditionType,
endpoint: 'https://_this_would_totally_fail.com',
parameters: {
'ids': 'ethereum',
'vs_currencies': 'usd',
ids: 'ethereum',
vs_currencies: 'usd',
},
query: '$.ethereum.usd',
returnValueTest: testReturnValueTest,
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit abb82b7

Please sign in to comment.