mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 19:54:41 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
32 lines
1.0 KiB
Ruby
32 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'discourse_sourcemapping_url_processor'
|
|
|
|
RSpec.describe DiscourseSourcemappingUrlProcessor do
|
|
def process(input)
|
|
env = Sprockets::Environment.new
|
|
env.context_class.class_eval do
|
|
def resolve(path, **kargs)
|
|
"/assets/mapped.js.map"
|
|
end
|
|
|
|
def asset_path(path, options = {})
|
|
"/assets/mapped-HEXGOESHERE.js.map"
|
|
end
|
|
end
|
|
|
|
input = { environment: env, data: input, name: 'mapped', filename: 'mapped.js', metadata: {} }
|
|
DiscourseSourcemappingUrlProcessor.call(input)[:data]
|
|
end
|
|
|
|
it 'maintains relative paths' do
|
|
output = process "var mapped;\n//# sourceMappingURL=mapped.js.map"
|
|
expect(output).to eq("var mapped;\n//# sourceMappingURL=mapped-HEXGOESHERE.js.map\n//!\n")
|
|
end
|
|
|
|
it 'uses default behaviour for non-adjacent relative paths' do
|
|
output = process "var mapped;\n//# sourceMappingURL=/assets/mapped.js.map"
|
|
expect(output).to eq("var mapped;\n//# sourceMappingURL=/assets/mapped-HEXGOESHERE.js.map\n//!\n")
|
|
end
|
|
end
|