customer_saved_search_test.rb 1.1 KB

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