DEV: ensures highlightjs is correctly tested (#9923)

This commit is contained in:
Joffrey JAFFEUX 2020-05-29 13:05:44 +02:00 committed by GitHub
parent 5d792483f0
commit 7635c18a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 221 additions and 0 deletions

View File

@ -177,6 +177,11 @@ task 'javascript:update' do
puts "Cleanup unused styles folder"
system("rm -rf node_modules/highlight.js/build/styles")
langs_dir = 'vendor/assets/javascripts/highlightjs/languages/*.min.js'
langs = Dir.glob(langs_dir).map { |lang| File.basename(lang).split('.')[0] }
test_bundle_dest = 'vendor/assets/javascripts/highlightjs/highlight-test-bundle.min.js'
File.write(test_bundle_dest, HighlightJs.bundle(langs))
end
if src.include? "ace-builds"

View File

@ -0,0 +1,22 @@
import componentTest from "helpers/component-test";
moduleForComponent("highlighted-code", { integration: true });
componentTest("highlighting code", {
template: "{{highlighted-code lang='ruby' code=code}}",
beforeEach() {
Discourse.HighlightJSPath =
"assets/highlightjs/highlight-test-bundle.min.js";
this.set("code", "def test; end");
},
async test(assert) {
assert.equal(
find("code.ruby.hljs .hljs-function .hljs-keyword")
.text()
.trim(),
"def"
);
}
});

File diff suppressed because one or more lines are too long