Skip to content

Commit 9b6aef6

Browse files
committed
Add failing tests
Added a test case for the more compact version of the pin, where the CDN url is not used.
1 parent 9eec49a commit 9b6aef6

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pin 'md5', to: 'https://cdn.skypack.dev/[email protected]', preload: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pin 'md5', preload: true #@2.2.0

test/npm_test.rb

+28
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,34 @@ class Importmap::NpmTest < ActiveSupport::TestCase
1818
end
1919
end
2020

21+
test "successful outdated packages using single-quotes with mock" do
22+
npm = Importmap::Npm.new(file_fixture("single_quote_outdated_import_map.rb"))
23+
response = { "dist-tags" => { "latest" => '2.3.0' } }.to_json
24+
25+
npm.stub(:get_json, response) do
26+
outdated_packages = npm.outdated_packages
27+
28+
assert_equal(1, outdated_packages.size)
29+
assert_equal('md5', outdated_packages[0].name)
30+
assert_equal('2.2.0', outdated_packages[0].current_version)
31+
assert_equal('2.3.0', outdated_packages[0].latest_version)
32+
end
33+
end
34+
35+
test "successful outdated packages using single-quotes and without CDN with mock" do
36+
npm = Importmap::Npm.new(file_fixture("single_quote_outdated_import_map_without_cdn.rb"))
37+
response = { "dist-tags" => { "latest" => '2.3.0' } }.to_json
38+
39+
npm.stub(:get_json, response) do
40+
outdated_packages = npm.outdated_packages
41+
42+
assert_equal(1, outdated_packages.size)
43+
assert_equal('md5', outdated_packages[0].name)
44+
assert_equal('2.2.0', outdated_packages[0].current_version)
45+
assert_equal('2.3.0', outdated_packages[0].latest_version)
46+
end
47+
end
48+
2149
test "missing outdated packages with mock" do
2250
response = { "error" => "Not found" }.to_json
2351

0 commit comments

Comments
 (0)