-
-
Save shankardevy/f0127229cb2ba2624ab51b62cf7caca5 to your computer and use it in GitHub Desktop.
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
defmodule Mango.CRMTest do | |
use Mango.DataCase | |
alias Mango.CRM | |
alias Mango.CRM.Customer | |
test "build_customer/0 returns a customer changeset" do | |
assert %Ecto.Changeset{data: %Customer{}} = CRM.build_customer | |
end | |
test "build_customer/1 returns a customer changeset with values applied" do | |
attrs = %{"name" => "John"} | |
changeset = CRM.build_customer(attrs) | |
assert changeset.params == attrs | |
end | |
# >>> Add these two tests from here. | |
test "create_customer/1 returns a customer for valid data" do | |
valid_attrs = %{ | |
"name" => "John", | |
"email" => "john@example.com", | |
"password" => "secret", | |
"residence_area" => "Area 1", | |
"phone" => "1111" | |
} | |
assert {:ok, customer} = CRM.create_customer(valid_attrs) | |
assert Comeonin.Bcrypt.checkpw(valid_attrs["password"], customer.password_hash) | |
end | |
test "create_customer/1 returns a changeset for invalid data" do | |
invalid_attrs = %{} | |
assert {:error, %Ecto.Changeset{}} = CRM.create_customer(invalid_attrs) | |
end | |
# <<< Upto here. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment