Skip to content

Commit

Permalink
Fix tests that broke when generator behavior changed
Browse files Browse the repository at this point in the history
  • Loading branch information
denisahearn committed Dec 6, 2024
1 parent d72e78d commit fe16dba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
10 changes: 0 additions & 10 deletions test/graphql-docs/fixtures/named-root-schema.graphql

This file was deleted.

24 changes: 5 additions & 19 deletions test/graphql-docs/generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def setup
@tiny_parser = GraphQLDocs::Parser.new(tiny_schema, {})
@tiny_results = @tiny_parser.parse

named_root_schema = File.read(File.join(fixtures_dir, 'named-root-schema.graphql'))
@named_root_parser = GraphQLDocs::Parser.new(named_root_schema, {})
@named_root_results = @named_root_parser.parse

@output_dir = File.join(fixtures_dir, 'output')
end

Expand Down Expand Up @@ -66,6 +62,7 @@ def test_that_it_works
assert File.exist? File.join(@output_dir, 'enum', 'issuestate', 'index.html')
assert File.exist? File.join(@output_dir, 'input_object', 'projectorder', 'index.html')
assert File.exist? File.join(@output_dir, 'interface', 'reactable', 'index.html')
assert File.exist? File.join(@output_dir, 'query', 'codeofconduct', 'index.html')
assert File.exist? File.join(@output_dir, 'mutation', 'addcomment', 'index.html')
assert File.exist? File.join(@output_dir, 'object', 'repository', 'index.html')
assert File.exist? File.join(@output_dir, 'scalar', 'boolean', 'index.html')
Expand Down Expand Up @@ -136,18 +133,6 @@ def test_that_it_sets_classes
assert_match(/<div class="field-entry my-4">/, object)
end

def test_that_named_query_root_generates_fields
options = deep_copy(GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS)
options[:output_dir] = @output_dir

generator = GraphQLDocs::Generator.new(@named_root_results, options)
generator.generate

object = File.read File.join(@output_dir, 'operation', 'query', 'index.html')

assert_match(/Do a thing/, object)
end

def test_that_missing_landing_pages_are_reported
options = deep_copy(GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS)
options[:landing_pages][:index] = 'BOGUS'
Expand Down Expand Up @@ -202,9 +187,9 @@ def test_that_empty_html_lines_not_interpreted_by_markdown
generator = GraphQLDocs::Generator.new(@tiny_results, options)
generator.generate

contents = File.read File.join(@output_dir, 'operation', 'query', 'index.html')
contents = File.read File.join(@output_dir, 'query', 'codeofconduct', 'index.html')

assert_match(%r{<td>\s+<p>The code of conduct's key</p>\s+</td>}, contents)
assert_match(%r{<p>The code of conduct's key</p>}, contents)
end

def test_that_non_empty_html_lines_not_interpreted_by_markdown
Expand All @@ -216,6 +201,7 @@ def test_that_non_empty_html_lines_not_interpreted_by_markdown

contents = File.read File.join(@output_dir, 'input_object', 'projectorder', 'index.html')

assert_match %r{<div class="description-wrapper">\n <p>The direction in which to order projects by the specified field.</p>\s+</div>}, contents
assert_match %r{<div class="description-wrapper">\n <p>The direction in which to order projects by the specified field.</p>\s+</div>},
contents
end
end

0 comments on commit fe16dba

Please sign in to comment.