Replaced tests with jest

This commit is contained in:
2022-02-20 20:10:08 +00:00
parent f2994fc52e
commit ca11cc8963
23 changed files with 7595 additions and 1019 deletions

View File

@@ -4,7 +4,7 @@ const { eatBlock, checkAlphaNumeric } = require('./utils');
const parseInput = require('./parse-input');
//parse the schema into a type graph
const buildTypeGraph = (schema, options) => {
const buildTypeGraph = (schema, options = {}) => {
//the default graph
let graph = {
String: { typeName: 'String', scalar: true },

View File

@@ -40,7 +40,7 @@ const sineQL = (schema, { queryHandlers, createHandlers }, options = {}) => {
case 'update':
case 'delete':
return [501, 'Keyword not implemented: ' + tokens[0]];
return [501, 'Keyword not yet implemented: ' + tokens[0]];
//TODO: implement these keywords
break;

View File

@@ -1,5 +1,5 @@
//build the tokens into a single object of types representing the initial query
const parseCreateTree = (tokens, typeGraph, options) => {
const parseCreateTree = (tokens, typeGraph, options = {}) => {
let current = 1; //primed
//check this is a create command
@@ -94,6 +94,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
//insert the typename into the block
block['typeName'] = typeGraph[superType][fieldName].typeName;
//insert the unique modifier if it's set
block['unique'] = typeGraph[superType][fieldName].unique;
//insert the block-level modifier signal
if (modifier) {
block[modifier] = true;
@@ -122,6 +125,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
//save the typeGraph type into result
result[fieldName] = JSON.parse(JSON.stringify( typeGraph[ typeGraph[superType][fieldName].typeName ] ));
//insert the unique modifier if it's set
result[fieldName]['unique'] = typeGraph[superType][fieldName].unique;
//insert the block-level modifier signal
if (modifier) {
result[fieldName][modifier] = tokens[current++];

View File

@@ -1,5 +1,5 @@
//break the body down into tokens
const parseInput = (body, allowStrings, options) => {
const parseInput = (body, allowStrings, options = {}) => {
let current = 0;
tokens = [];

View File

@@ -1,5 +1,5 @@
//build the tokens into a single object of types representing the initial query
const parseQueryTree = (tokens, typeGraph, options) => {
const parseQueryTree = (tokens, typeGraph, options = {}) => {
let current = 1; //primed
//get a token that matches a type
@@ -60,6 +60,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
//insert the typename into the block
block['typeName'] = typeGraph[superType][fieldName].typeName;
//insert the unique modifier if it's set
block['unique'] = typeGraph[superType][fieldName].unique;
//insert into result
result[fieldName] = block;
@@ -83,6 +86,9 @@ const readBlock = (tokens, current, superType, typeGraph, options) => {
//save the typeGraph type into result
result[fieldName] = JSON.parse(JSON.stringify( typeGraph[ typeGraph[superType][fieldName].typeName ] ));
//insert the unique modifier if it's set
result[fieldName]['unique'] = typeGraph[superType][fieldName].unique;
//insert the block-level modifier signal
if (modifier) {
result[fieldName][modifier] = tokens[current++];