Skip to content

Commit 1cc3c53

Browse files
committed
test multiple editors
1 parent b338e19 commit 1cc3c53

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

Diff for: cypress/e2e/spec.cy.ts

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
describe('Editor Test', () => {
22
it('displays the editor', () => {
33
cy.visit('http://localhost:5173/')
4-
cy.contains('#check Nat')
4+
cy.contains('#check 0')
55
.should(($p) => {
66
// ...
77
expect(getComputedStyle($p.get(0)).fontFamily).to.match(/^JuliaMono/)
88
})
99
})
10+
1011
it('displays the infoview', () => {
1112
cy.visit('http://localhost:5173/')
1213
cy.get('.squiggly-info')
13-
cy.iframe().contains('Nat : Type')
14+
cy.iframe().contains('0 : Nat')
1415
})
15-
it('changes themes', () => {
1616

17+
it('changes themes', () => {
1718
cy.visit('http://localhost:5173/')
1819
cy.get('[data-cy="theme-light"]').click()
19-
cy.contains('#check Nat')
20+
cy.contains('#check 0')
2021
.should(($p) => {
2122
expect(getComputedStyle($p.get(0)).getPropertyValue('--vscode-editor-background')).to.equal("#ffffff")
2223
})
2324
cy.get('[data-cy="theme-dark"]').click()
24-
cy.contains('#check Nat')
25+
cy.contains('#check 0')
2526
.should(($p) => {
2627
expect(getComputedStyle($p.get(0)).getPropertyValue('--vscode-editor-background')).to.equal("#1e1e1e")
2728
})
2829
})
30+
2931
it('inputs unicode', () => {
3032
cy.visit('http://localhost:5173/')
3133
cy.get('[data-cy="leader-backslash"]').click()
32-
cy.contains('#check Nat').click("left")
34+
cy.contains('#check 0').click("left")
3335
cy.get('body').type('\\alpha')
3436
cy.contains('α')
3537
cy.get('[data-cy="leader-comma"]').click()
36-
cy.contains('#check Nat').click("left")
38+
cy.contains('α#check 0').click("left")
3739
cy.get('body').type(',beta')
38-
cy.contains('β')
40+
cy.contains('βα#check 0')
41+
})
42+
43+
it('allows for multiple editors', () => {
44+
cy.visit('http://localhost:5173/')
45+
cy.contains('#check 0')
46+
cy.get('[data-cy="number-editors"]').type('{selectall}').type('2')
47+
cy.contains('#check 1')
48+
cy.contains('#check 0')
49+
cy.get('.squiggly-info')
50+
cy.contains('#check 1').click()
51+
cy.iframe().contains('1 : Nat')
52+
cy.contains('#check 0').click()
53+
cy.iframe().contains('0 : Nat')
3954
})
4055
})

Diff for: demo/src/App.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function App() {
2828
>Input Leader ","</button>
2929
<input type="number" min="1" max="3"
3030
value={numberEditors}
31+
data-cy="number-editors"
3132
onChange={(event) => {
3233
setNumberEditors(parseInt(event.target.value));
3334
}}

Diff for: demo/src/LeanMonaco.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function LeanMonacoComponent({options, numberEditors} : {options: LeanMonacoOpti
2626
<>
2727
<LeanMonacoContext.Provider value={leanMonaco}>
2828
{[...Array(numberEditors)].map((x, i) =>
29-
<LeanMonacoEditorComponent key={i} fileName={`/project/test${i}.lean`}/>
29+
<LeanMonacoEditorComponent key={i} fileName={`/project/test${i}.lean`} value={`#check ${i}`}/>
3030
)}
3131
<div className='infoview' ref={infoviewRef}></div>
3232
</LeanMonacoContext.Provider>

Diff for: demo/src/LeanMonacoEditor.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useRef, useContext } from 'react'
22
import { LeanMonacoEditor } from 'lean4monaco'
33
import { LeanMonacoContext } from './LeanMonaco'
44

5-
function LeanMonacoEditorComponent({fileName}: {fileName: string}) {
5+
function LeanMonacoEditorComponent({fileName, value}: {fileName: string, value: string}) {
66
const codeviewRef = useRef<HTMLDivElement>(null)
77
const leanMonaco = useContext(LeanMonacoContext)
88

@@ -12,7 +12,7 @@ function LeanMonacoEditorComponent({fileName}: {fileName: string}) {
1212

1313
;(async () => {
1414
await leanMonaco!.whenReady
15-
await leanMonacoEditor.start(codeviewRef.current!, fileName, '#check Nat')
15+
await leanMonacoEditor.start(codeviewRef.current!, fileName, value)
1616
})()
1717

1818
return () => {

0 commit comments

Comments
 (0)