1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-06 00:32:34 -04:00
httparrot/test/user_agent_test.exs
Eduardo Gurgel a049031f67 Rewrite tests to be less integrated
Now mocking JSEX
2013-12-30 23:37:18 -03:00

25 lines
568 B
Elixir

defmodule HTTParrot.UserAgentHandlerTest do
use ExUnit.Case
import :meck
import HTTParrot.UserAgentHandler
setup do
new :cowboy_req
new JSEX
end
teardown do
unload :cowboy_req
unload JSEX
end
test "returns prettified json with user agent" do
expect(:cowboy_req, :header, [{["user-agent", :req1, "null"], {:user_agent, :req2}}])
expect(JSEX, :encode!, [{[[{"user-agent", :user_agent}]], :json}])
assert get_json(:req1, :state) == {:json, :req2, :state}
assert validate :cowboy_req
assert validate JSEX
end
end