|
1 | | -const katex = await import('katex/dist/katex'); // This version of import is essential for mhchem |
| 1 | +import './jquery-easyui/jquery.easyui.min'; // ADDED for unit test |
| 2 | +const katex = await import('katex/dist/katex'); // This version of import is essential for mhchem |
2 | 3 | await import('katex/dist/contrib/mhchem'); |
3 | 4 | const CodeMirror = (await import('codemirror')).default; |
4 | 5 | await import('codemirror/mode/stex/stex'); // manual recommendation |
@@ -30,10 +31,10 @@ export class MathFormulae implements IMath { |
30 | 31 | * Constructor. |
31 | 32 | */ |
32 | 33 | constructor( |
33 | | - @inject(localizerId) localizer: ILocalizer, |
34 | | - @inject(parametersId) parameters: any, |
35 | | - @inject(parserId) parser: IParser, |
36 | | - @inject(messagerId) messager: IMessager |
| 34 | + @inject(localizerId) localizer: ILocalizer|null, |
| 35 | + @inject(parametersId) parameters: any|null, |
| 36 | + @inject(parserId) parser: IParser|null, |
| 37 | + @inject(messagerId) messager: IMessager|null |
37 | 38 | ) { |
38 | 39 | this.mathTextInput = document.getElementById('mathTextInput'); |
39 | 40 | this.mathVisualOutput = document.getElementById('mathVisualOutput'); |
@@ -62,13 +63,16 @@ export class MathFormulae implements IMath { |
62 | 63 | }); |
63 | 64 |
|
64 | 65 | (codeMirrorEditor as ICodeMirror).version = CodeMirror.version; |
65 | | - let panelOptions = $('#divMathTextInput').panel('options'); |
66 | | - panelOptions.onResize = function(width: string|number, height: string|number) { |
67 | | - try { |
68 | | - codeMirrorEditor.setSize(width, height); |
69 | | - codeMirrorEditor.refresh(); |
70 | | - } catch(e) { } |
71 | | - }; |
| 66 | + // PURPOSE of this clause is to overcome the exception in unit test. Mocking did not help. |
| 67 | + try { |
| 68 | + let panelOptions = $('#divMathTextInput').panel('options'); |
| 69 | + panelOptions.onResize = function(width: string|number, height: string|number) { |
| 70 | + try { |
| 71 | + codeMirrorEditor.setSize(width, height); |
| 72 | + codeMirrorEditor.refresh(); |
| 73 | + } catch(e) { } |
| 74 | + }; |
| 75 | + } catch(e) { console.warn(`Could not apply 'panel' : ${typeof $('#divMathTextInput').panel} : ${e}`); } |
72 | 76 |
|
73 | 77 | return codeMirrorEditor as ICodeMirror; |
74 | 78 | } |
|
0 commit comments