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