customer_saved_search_test.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'test_helper'
  2. class CustomerSavedSearchTest < Test::Unit::TestCase
  3. def setup
  4. super
  5. load_customer_saved_search
  6. end
  7. def test_get_customers_from_customer_saved_search
  8. fake(
  9. 'customers/search.json?customer_saved_search_id=8899730',
  10. body: load_fixture('customer_saved_search_customers'),
  11. extension: false
  12. )
  13. assert_equal(1, @customer_saved_search.customers.length)
  14. assert_equal(112223902, @customer_saved_search.customers.first.id)
  15. end
  16. def test_get_customers_from_customer_saved_search_with_params
  17. fake(
  18. 'customers/search.json?customer_saved_search_id=8899730&limit=1',
  19. body: load_fixture('customer_saved_search_customers'),
  20. extension: false
  21. )
  22. customers = @customer_saved_search.customers(limit: 1)
  23. assert_equal(1, customers.length)
  24. assert_equal(112223902, customers.first.id)
  25. end
  26. private
  27. def load_customer_saved_search
  28. fake('customer_saved_searches/8899730', body: load_fixture('customer_saved_search'))
  29. @customer_saved_search = ShopifyAPI::CustomerSavedSearch.find(8899730)
  30. end
  31. end