Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Test that an invalid argument returns null

Marcin Gębalae2b79b31a2d2
diff --git a/tests/api/test_menu.py b/tests/api/test_menu.py
index 8f64db44c5..49c7cf8d29 100644
--- a/tests/api/test_menu.py
+++ b/tests/api/test_menu.py
@@ -32,6 +32,14 @@ def test_menu_query(user_api_client, menu):
assert 'errors' not in content
assert content['data']['menu']['name'] == menu.name
+ # test query by invalid name returns null
+ variables = json.dumps({'menu_name': 'not-a-menu'})
+ response = user_api_client.post(
+ reverse('api'), {'query': query, 'variables': variables})
+ content = get_graphql_content(response)
+ assert 'errors' not in content
+ assert not content['data']['menu']
+
def test_menus_query(user_api_client, menu, menu_item):
query = """