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

47
test/parse-input.test.js Normal file
View File

@@ -0,0 +1,47 @@
const parseInput = require('../source/parse-input');
const schema = `
scalar Date
type Book {
unique String title
Date published
Float rating
}
type Author {
unique String name
Book books
}
`;
const query = `
Book {
title "The wind in the willows"
}
`;
const mushedQuery = 'Book{title"published"}'; //this is strange lol
//parse the input with no concern for validity of the structure
test('parseInput - generate the lexemes', () => {
const tokens = parseInput(schema, false, { debug: false });
expect(tokens.length).toEqual(22); //each lexeme becomes a token
});
test('parseInput - generate the lexemes (with strings enabled)', () => {
const tokens = parseInput(query, true, { debug: false });
expect(tokens.length).toEqual(5); //each lexeme becomes a token
});
test('parseInput - generate the lexemes (with strings enabled)', () => {
const tokens = parseInput(mushedQuery, true, { debug: false });
expect(tokens.length).toEqual(5); //each lexeme becomes a token
});