Skip to content

Commit

Permalink
Test that plugin/preset resolution only happens on the first call e…
Browse files Browse the repository at this point in the history
…xecution
  • Loading branch information
rmacklin committed Mar 12, 2017
1 parent 0e533c5 commit f49198e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/sprockets/bumble_d/transformer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,21 @@ def test_cache_works
assert_equal expected_output, transformer.call(input)
end

def test_it_resolves_plugin_arrays
def test_it_instantiates_resolver_only_the_first_time_call_is_invoked
input = input_exemplar
resolver = Resolver.new(Transformer::BabelBridge.new(File.expand_path(__dir__)))
Resolver.expects(:new).never

transformer = new_transformer(presets: ['es2015'])

Resolver.expects(:new).returns(resolver).once

transformer.call(input)
other_input = input_exemplar(data: 'const foo = "bar"')
transformer.call(other_input)
end

def test_it_resolves_plugin_arrays_the_first_time_call_is_invoked
input = input_exemplar
Resolver.any_instance.expects(:resolve_plugins).never

Expand All @@ -285,9 +299,13 @@ def test_it_resolves_plugin_arrays

Resolver.any_instance.expects(:resolve_plugins).with(plugins).once
transformer.call(input)

Resolver.any_instance.expects(:resolve_plugins).never
other_input = input_exemplar(data: 'const foo = "bar"')
transformer.call(other_input)
end

def test_it_resolves_preset_arrays
def test_it_resolves_preset_arrays_the_first_time_call_is_invoked
input = input_exemplar
Resolver.any_instance.expects(:resolve_presets).never

Expand All @@ -304,6 +322,10 @@ def test_it_resolves_preset_arrays

Resolver.any_instance.expects(:resolve_presets).with(presets).once
transformer.call(input)

Resolver.any_instance.expects(:resolve_presets).never
other_input = input_exemplar(data: 'const foo = "bar"')
transformer.call(other_input)
end

private
Expand Down

0 comments on commit f49198e

Please sign in to comment.