use proptest::prelude::*;
use crate::tests::property_tests::generators::documents::arb_executable_document;
use crate::tests::property_tests::generators::documents::arb_mixed_document;
use crate::tests::property_tests::generators::documents::arb_schema_document;
use crate::tests::property_tests::proptest_config;
use crate::GraphQLParser;
use crate::GraphQLParserConfig;
proptest! {
#![proptest_config(proptest_config())]
#[test]
fn schema_documents_parse_without_errors(
source in arb_schema_document(4)
) {
let result = GraphQLParser::new(&source).parse_schema_document();
prop_assert!(
!result.has_errors(),
"Schema document should parse without errors.\n\
Source:\n{}\n\nErrors:\n{}",
source,
result.formatted_errors(),
);
}
#[test]
fn executable_documents_parse_without_errors(
source in arb_executable_document(4)
) {
let result = GraphQLParser::new(&source).parse_executable_document();
prop_assert!(
!result.has_errors(),
"Executable document should parse without errors.\n\
Source:\n{}\n\nErrors:\n{}",
source,
result.formatted_errors(),
);
}
#[test]
fn mixed_documents_parse_without_errors(
source in arb_mixed_document(4)
) {
let result = GraphQLParser::new(&source).parse_mixed_document();
prop_assert!(
!result.has_errors(),
"Mixed document should parse without errors.\n\
Source:\n{}\n\nErrors:\n{}",
source,
result.formatted_errors(),
);
}
#[test]
fn schema_documents_parse_in_lean_mode(
source in arb_schema_document(4)
) {
let result = GraphQLParser::with_config(
&source,
GraphQLParserConfig::lean(),
).parse_schema_document();
prop_assert!(
!result.has_errors(),
"Schema document should parse in lean mode.\n\
Source:\n{}\n\nErrors:\n{}",
source,
result.formatted_errors(),
);
}
#[test]
fn executable_documents_parse_in_lean_mode(
source in arb_executable_document(4)
) {
let result = GraphQLParser::with_config(
&source,
GraphQLParserConfig::lean(),
).parse_executable_document();
prop_assert!(
!result.has_errors(),
"Executable document should parse in lean mode.\n\
Source:\n{}\n\nErrors:\n{}",
source,
result.formatted_errors(),
);
}
}