2020-05-29 13:05:44 +02:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
|
2020-07-07 18:51:19 +03:00
|
|
|
const LONG_CODE_BLOCK = "puts a\n".repeat(15000);
|
|
|
|
|
2020-05-29 13:05:44 +02:00
|
|
|
moduleForComponent("highlighted-code", { integration: true });
|
|
|
|
|
|
|
|
componentTest("highlighting code", {
|
|
|
|
template: "{{highlighted-code lang='ruby' code=code}}",
|
|
|
|
|
|
|
|
beforeEach() {
|
2020-08-17 15:44:39 -04:00
|
|
|
this.session.highlightJsPath =
|
2020-07-15 13:52:35 +01:00
|
|
|
"assets/highlightjs/highlight-test-bundle.min.js";
|
|
|
|
this.set("code", "def test; end");
|
2020-05-29 13:05:44 +02:00
|
|
|
},
|
|
|
|
|
2020-09-01 09:50:49 +02:00
|
|
|
test(assert) {
|
2020-05-29 13:05:44 +02:00
|
|
|
assert.equal(
|
|
|
|
find("code.ruby.hljs .hljs-function .hljs-keyword").text().trim(),
|
|
|
|
"def"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2020-07-07 18:51:19 +03:00
|
|
|
|
2020-07-15 13:52:35 +01:00
|
|
|
componentTest("large code blocks are not highlighted", {
|
2020-07-07 18:51:19 +03:00
|
|
|
template: "{{highlighted-code lang='ruby' code=code}}",
|
|
|
|
|
|
|
|
beforeEach() {
|
2020-08-17 15:44:39 -04:00
|
|
|
this.session.highlightJsPath =
|
2020-07-15 13:52:35 +01:00
|
|
|
"assets/highlightjs/highlight-test-bundle.min.js";
|
|
|
|
this.set("code", LONG_CODE_BLOCK);
|
2020-07-07 18:51:19 +03:00
|
|
|
},
|
|
|
|
|
2020-09-01 09:50:49 +02:00
|
|
|
test(assert) {
|
2020-07-07 18:51:19 +03:00
|
|
|
assert.equal(find("code").text().trim(), LONG_CODE_BLOCK.trim());
|
|
|
|
},
|
|
|
|
});
|