Kaynağa Gözat

add tests for current, pending, etc, closes #38

Peter Schröder 11 yıl önce
ebeveyn
işleme
efe64f1749

+ 10 - 0
test/fixtures/recurring_application_charges.json

@@ -0,0 +1,10 @@
+{
+  "recurring_application_charges": [
+    {
+      "name": "Super Duper Plan",
+      "price": 10.0,
+      "return_url": "http://super-duper.shopifyapps.com",
+      "status": "active"
+    }
+  ]
+}

+ 21 - 0
test/recurring_application_charge_test.rb

@@ -0,0 +1,21 @@
+require 'test_helper'
+
+class RecurringApplicationChargeTest < Test::Unit::TestCase
+  context "#all" do
+    should "get all charges" do
+      fake "recurring_application_charges"
+
+      charges = ShopifyAPI::RecurringApplicationCharge.all
+      assert_equal "Super Duper Plan", charges.first.name
+    end
+  end
+
+
+  should "not fail when there are no charges" do
+    fake "recurring_application_charges", body: {recurring_application_charges: []}.to_json
+
+    assert_equal 0, ShopifyAPI::RecurringApplicationCharge.all.count
+    assert_equal nil, ShopifyAPI::RecurringApplicationCharge.current
+    assert_equal [], ShopifyAPI::RecurringApplicationCharge.pending
+  end
+end