From 1a59bf93c6ff0d13195eea98e5d2d27cd2ee8fc7 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Wed, 7 Aug 2024 14:52:17 +0100 Subject: [PATCH] fix: remove random scalar examples These example outputs produce random results - this is an issue, since it means that multiple runs of spectaql with the same input can very easily produce different output. Ideally, this shouldn't be the case, and all output should be as consistent and reproducible as possible. Signed-off-by: Justin Chadwell --- src/lib/common.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/lib/common.js b/src/lib/common.js index debecb18..52b1aa7e 100644 --- a/src/lib/common.js +++ b/src/lib/common.js @@ -43,22 +43,16 @@ const QUOTE_TAG_REGEX = new RegExp(QUOTE_TAG, 'g') const QUOTE_HTML = '"' const QUOTE_HTML_REGEX = new RegExp(QUOTE_HTML, 'g') -// Map Scalar types to example data to use fro them +// Map Scalar types to example data to use for them const SCALAR_TO_EXAMPLE = { - String: ['abc123', 'xyz789'], - Int: [123, 987], - Float: [123.45, 987.65], + String: 'abc123', + Int: 123, + Float: 123.45, Boolean: [true, false], - Date: [ - new Date(), - new Date(new Date().setMonth(new Date().getMonth() - 6).valueOf()), - ].map((date) => date.toISOString()), - DateTime: [ - new Date(), - new Date(new Date().setMonth(new Date().getMonth() - 6).valueOf()), - ].map((date) => date.toISOString()), + Date: (new Date(0)).toISOString(), + DateTime: (new Date(0)).toISOString(), JSON: SPECIAL_TAG + '{}' + SPECIAL_TAG, - ID: [4, '4'], + ID: '4', } function unwindTags(str) {