storefront_access_token_test.rb 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class StorefrontAccessTokenTest < Test::Unit::TestCase
  4. def test_create_storefront_access_token
  5. fake("storefront_access_tokens", method: :post, body: load_fixture('storefront_access_token'))
  6. storefront_access_token = ShopifyAPI::StorefrontAccessToken.create(title: 'Test')
  7. assert_equal(1, storefront_access_token.id)
  8. assert_equal("Test", storefront_access_token.title)
  9. end
  10. def test_delete_storefront_access_token
  11. fake('storefront_access_tokens/1', method: :get, status: 200, body: load_fixture('storefront_access_token'))
  12. fake('storefront_access_tokens/1', method: :delete, status: 200, body: 'destroyed')
  13. storefront_access_tokens = ShopifyAPI::StorefrontAccessToken.find(1)
  14. assert(storefront_access_tokens.destroy)
  15. end
  16. def test_get_storefront_access_tokens
  17. fake("storefront_access_tokens", method: :get, status: 201, body: load_fixture('storefront_access_tokens'))
  18. tokens = ShopifyAPI::StorefrontAccessToken.all
  19. assert_equal(2, tokens.size)
  20. assert_equal(1, tokens.first.id)
  21. assert_equal(2, tokens.last.id)
  22. assert_equal('Test 1', tokens.first.title)
  23. assert_equal('Test 2', tokens.last.title)
  24. end
  25. end