DEV: ensures highlightjs is correctly tested (#9923)
This commit is contained in:
parent
5d792483f0
commit
7635c18a14
|
@ -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"
|
||||
|
|
|
@ -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
Loading…
Reference in New Issue