Skip to content

Commit

Permalink
DomainEditor refactored tests
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-test-domain-code-test.js,
  • Loading branch information
JensLincke committed Nov 8, 2023
1 parent 257c5db commit 1a379f5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/domain-code-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,19 @@ describe('TreeSitter', () => {
})

describe('Domain Code', () => {
let livelyCodeMirror
let livelyCodeMirror, livelyReplacementCodeMirror

before("load", async () => {
livelyCodeMirror = await (<lively-code-mirror></lively-code-mirror>)

livelyReplacementCodeMirror = await (<lively-code-mirror></lively-code-mirror>)

livelyReplacementCodeMirror.editor.on("change", () => {
if (livelyReplacementCodeMirror.domainObject) {
DomainObject.edit(livelyReplacementCodeMirror.domainObject, livelyReplacementCodeMirror.value)
livelyReplacementCodeMirror.domainObject.updateReplacements()
}
})
});

describe('DomainObject', () => {
Expand Down Expand Up @@ -546,13 +555,16 @@ const b = a`
});

it('click on let and then on const replacement', () => {
let livelyCodeMirror = livelyReplacementCodeMirror

var sourceCode =
`// hello
let a = 3 + 4
const b = a`
livelyCodeMirror.value = sourceCode

let domainObject = TreeSitterDomainObject.fromSource(sourceCode)
livelyReplacementCodeMirror.domainObject = domainObject
domainObject.livelyCodeMirror = livelyCodeMirror
domainObject.replaceType('let', LetSmilyReplacementDomainObject)
domainObject.replaceType('const', ConstSmilyReplacementDomainObject)
Expand All @@ -566,11 +578,7 @@ const b = a`


letReplacement.onClick()

// TODO this should be called by the editor
DomainObject.edit(domainObject, livelyCodeMirror.value)
domainObject.updateReplacements()




var constReplacement = domainObject.children[2].children[0]
Expand All @@ -579,9 +587,6 @@ const b = a`


constReplacement.onClick()
// TODO this should be called by the editor
DomainObject.edit(domainObject, livelyCodeMirror.value)
domainObject.updateReplacements()


expect(livelyCodeMirror.value).to.match(/let b/)
Expand Down

0 comments on commit 1a379f5

Please sign in to comment.