2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/spec/integrity/js_constants_spec.rb
David Taylor e56a4bf03e DEV: Prepare for rename of app/assets/javascripts/ -> frontend/
This commit contains all the code changes. A followup will perform the actual move
2025-10-22 16:24:11 +01:00

23 lines
743 B
Ruby

# frozen_string_literal: true
RSpec.describe "constants match ruby" do
let(:ctx) { MiniRacer::Context.new }
def parse(file)
# mini racer doesn't handle JS modules so we'll do this hack
source = File.read("#{Rails.root}/frontend/#{file}")
source.gsub!(/^export */, "")
ctx.eval(source)
end
it "has the correct values" do
parse("discourse/app/lib/constants.js")
parse("pretty-text/addon/emoji/version.js")
priorities = ctx.eval("SEARCH_PRIORITIES")
Searchable::PRIORITIES.each { |key, value| expect(priorities[key.to_s]).to eq(value) }
expect(ctx.eval("SEARCH_PHRASE_REGEXP")).to eq(Search::PHRASE_MATCH_REGEXP_PATTERN)
expect(ctx.eval("IMAGE_VERSION")).to eq(Emoji::EMOJI_VERSION)
end
end