-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f49ab1e
commit cceba1b
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start() |