Skip to content

Commit

Permalink
Add assertion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshrieken committed Jul 18, 2016
1 parent f49ab1e commit cceba1b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
89 changes: 89 additions & 0 deletions test/assertions_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
defmodule TestThatJson.AssertionsTest do
use ExUnit.Case, async: true

import TestThatJson.Assertions

test "is_json_equal" do
json = "[1,2,3]"

assert is_json_equal(json, json)
end

test "has_json_keys" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_json_keys(json, ["key1", "key2"])
end

test "has_only_json_keys" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_only_json_keys(json, ["key1", "key2"])
end

test "has_json_values" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_json_values(json, ["value", "data"])
end

test "has_only_json_values" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_only_json_values(json, ["value", "data"])
end

test "has_json_properties" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_json_properties(json, %{"key1" => "value", "key2" => "data"})
end

test "has_only_json_properties" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_only_json_properties(json, %{"key1" => "value", "key2" => "data"})
end

test "has_json_path" do
json = """
{
"key1": "value",
"key2": "data"
}
"""

assert has_json_path(json, "key1")
end
end

1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()

0 comments on commit cceba1b

Please sign in to comment.