Skip to content

Commit

Permalink
Add test for context variables within various properties of a JsonApi…
Browse files Browse the repository at this point in the history
…Condition.
  • Loading branch information
derekpierre committed Oct 29, 2024
1 parent 521d56e commit 6d4babe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/taco/test/conditions/base/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { describe, expect, it } from 'vitest';
import {
JsonApiCondition,
jsonApiConditionSchema,
JsonApiConditionType,
} from '../../../src/conditions/base/json-api';
import { testJsonApiConditionObj } from '../../test-utils';

Expand Down Expand Up @@ -95,5 +96,31 @@ describe('JsonApiCondition', () => {
expect(result.data).toEqual(noParamsObj);
});
});

describe('context variables', () => {
it('allow context variables for various values including as substring', () => {
const jsonApiConditionObj = {
conditionType: JsonApiConditionType,
endpoint:
'https://api.coingecko.com/api/:version/simple/:endpointPath',
parameters: {
ids: 'ethereum',
vs_currencies: ':vsCurrency',
},
query: 'ethereum.:vsCurrency',
authorizationToken: ':authToken',
returnValueTest: {
comparator: '==',
value: ':expectedPrice',
},
};
const result = JsonApiCondition.validate(
jsonApiConditionSchema,
jsonApiConditionObj,
);
expect(result.error).toBeUndefined();
expect(result.data).toEqual(jsonApiConditionObj);
});
});
});
});

0 comments on commit 6d4babe

Please sign in to comment.