Pārlūkot izejas kodu

Improve checkouts and abandoned checkouts tests

Emmanuel Milou 6 gadi atpakaļ
vecāks
revīzija
323a623e5f
2 mainītis faili ar 12 papildinājumiem un 4 dzēšanām
  1. 3 2
      test/abandoned_checkouts_test.rb
  2. 9 2
      test/checkouts_test.rb

+ 3 - 2
test/abandoned_checkouts_test.rb

@@ -5,7 +5,8 @@ require 'test_helper'
 class AbandonedCheckoutsTest < Test::Unit::TestCase
   test ":get lists all abandoned checkouts indexed by id" do
     fake 'checkouts', method: :get, status: 200, body: load_fixture('checkouts')
-    abandoned_checkout = ShopifyAPI::AbandonedCheckout.all
-    assert_equal 450789469, abandoned_checkout.first.id
+    abandoned_checkouts = ShopifyAPI::AbandonedCheckout.all
+    assert_equal 450789469, abandoned_checkouts.first.id
+    assert_equal JSON.parse(load_fixture('checkouts'))['checkouts'].size, abandoned_checkouts.size
   end
 end

+ 9 - 2
test/checkouts_test.rb

@@ -1,10 +1,17 @@
 require 'test_helper'
 
 class CheckoutsTest < Test::Unit::TestCase
+  test ":create creates a checkout" do
+    fake 'checkouts', method: :post, status: 201, body: load_fixture('checkout')
+    checkout = ShopifyAPI::Checkout.create
+    assert_equal "2a1ace52255252df566af0faaedfbfa7", checkout.id
+  end
+
   test "get all checkouts indexed by token" do
     fake 'checkouts', method: :get, status: 200, body: load_fixture('checkouts')
-    checkout = ShopifyAPI::Checkout.all
-    assert_equal '2a1ace52255252df566af0faaedfbfa7', checkout.first.id
+    checkouts = ShopifyAPI::Checkout.all
+    assert_equal '2a1ace52255252df566af0faaedfbfa7', checkouts.first.id
+    assert_equal JSON.parse(load_fixture('checkouts'))['checkouts'].size, checkouts.size
   end
 
   test ":complete completes a checkout" do