Rewrite tests (#948)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2021-01-15 22:54:43 +01:00 committed by GitHub
parent 9f6b1a9a46
commit 908a5ce984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 286 additions and 398 deletions

View file

@ -12,12 +12,26 @@ declare namespace Cypress {
* @example cy.get(input).fill('content')
*/
fill (value: string): Chainable<Element>
codemirrorFill (value: string): Chainable<Element>
}
}
Cypress.Commands.add('fill', {
prevSubject: 'element'
}, (subject, value) => {
cy.wrap(subject).invoke('val', value)
.trigger('change', { force: true })
return cy.wrap(subject)
.invoke('val', value)
.trigger('change', { force: true })
})
Cypress.Commands.add('codemirrorFill', (content: string) => {
const line = content.split("\n").find(value => value !== '');
cy.get('.CodeMirror')
.click()
.get('textarea')
.fill(content)
if(line) {
cy.get('.CodeMirror')
.contains('.CodeMirror-line', line)
}
})