script_tag_test.rb 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. require 'test_helper'
  3. class ScriptTagTest < Test::Unit::TestCase
  4. test "get all should get all script tags" do
  5. fake('script_tags', method: :get, status: 200, body: load_fixture('script_tags'))
  6. script_tags = ShopifyAPI::ScriptTag.all
  7. assert_equal("http://js-aplenty.com/bar.js", script_tags.first.src)
  8. end
  9. test "get should get a script tag" do
  10. fake('script_tags/421379493', method: :get, status: 200, body: load_fixture('script_tag'))
  11. script_tag = ShopifyAPI::ScriptTag.find(421379493)
  12. assert_equal("http://js-aplenty.com/bar.js", script_tag.src)
  13. end
  14. test "create should create a new script tag" do
  15. fake('script_tags', method: :post, status: 201, body: load_fixture('script_tag'))
  16. script_tag = ShopifyAPI::ScriptTag.create(event: "onload", src: "http://js-aplenty.com/bar.js")
  17. assert_equal("http://js-aplenty.com/bar.js", script_tag.src)
  18. end
  19. test "editing script tag should update script tag" do
  20. fake('script_tags/421379493', method: :get, status: 200, body: load_fixture('script_tag'))
  21. script_tag = ShopifyAPI::ScriptTag.find(421379493)
  22. script_tag.src = "http://js-aplenty.com/bar.js"
  23. fake('script_tags/421379493', method: :put, status: 200, body: load_fixture('script_tag'))
  24. script_tag.save
  25. assert_equal("http://js-aplenty.com/bar.js", script_tag.src)
  26. end
  27. end