From 6d4babe7bb5ea5df8397c814d362a204d9216116 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Mon, 28 Oct 2024 09:35:55 -0400 Subject: [PATCH] Add test for context variables within various properties of a JsonApiCondition. --- .../taco/test/conditions/base/json.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/taco/test/conditions/base/json.test.ts b/packages/taco/test/conditions/base/json.test.ts index 5f8ea045..cc04fe31 100644 --- a/packages/taco/test/conditions/base/json.test.ts +++ b/packages/taco/test/conditions/base/json.test.ts @@ -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'; @@ -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); + }); + }); }); });