Skip to content

Commit

Permalink
Merge pull request #293 from snewcomer/fixup-plan-tests
Browse files Browse the repository at this point in the history
Fixup plan tests
  • Loading branch information
joshsmith authored Nov 21, 2017
2 parents 11f789e + f0f950f commit 10e5fd1
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions test/stripe/subscriptions/plan_test.exs
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
defmodule Stripe.PlanTest do
use Stripe.StripeCase, async: true

test "is listable" do
assert {:ok, %Stripe.List{data: plans}} = Stripe.Plan.list()
assert_stripe_requested :get, "/v1/plans"
assert is_list(plans)
assert %Stripe.Plan{} = hd(plans)
describe "create/2" do
test "creates a Plan for a customer" do
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.create(%{
amount: 5000,
interval: "month",
name: "Sapphire elite",
currency: "usd",
id: "sapphire-elite"})
assert_stripe_requested :post, "/v1/plans"
end
end

test "is retrievable" do
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.retrieve("sapphire-elite")
assert_stripe_requested :get, "/v1/plans/sapphire-elite"
describe "retrieve/2" do
test "retrieves a Plan" do
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.retrieve("sapphire-elite")
assert_stripe_requested :get, "/v1/plans/sapphire-elite"
end
end

test "is creatable" do
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.create(%{
amount: 5000,
interval: "month",
name: "Sapphire elite",
currency: "usd",
id: "sapphire-elite"
})
assert_stripe_requested :post, "/v1/plans"
describe "update/2" do
test "updates a Plan" do
assert {:ok, plan} = Stripe.Plan.update("sapphire-elite", %{metadata: %{foo: "bar"}})
assert_stripe_requested :post, "/v1/plans/#{plan.id}"
end
end

test "is updateable" do
assert {:ok, plan} = Stripe.Plan.update("sapphire-elite", %{metadata: %{foo: "bar"}})
assert_stripe_requested :post, "/v1/plans/#{plan.id}"
describe "delete/2" do
test "deletes a Plan" do
{:ok, plan} = Stripe.Plan.retrieve("sapphire-elite")
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.delete(plan)
assert_stripe_requested :delete, "/v1/plans/#{plan.id}"
end
end

test "is deletable" do
{:ok, plan} = Stripe.Plan.retrieve("sapphire-elite")
assert {:ok, %Stripe.Plan{}} = Stripe.Plan.delete(plan)
assert_stripe_requested :delete, "/v1/plans/#{plan.id}"
describe "list/2" do
test "lists all Plans" do
assert {:ok, %Stripe.List{data: plans}} = Stripe.Plan.list()
assert_stripe_requested :get, "/v1/plans"
assert is_list(plans)
assert %Stripe.Plan{} = hd(plans)
end
end
end
end

0 comments on commit 10e5fd1

Please sign in to comment.