Improve tests (#944)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2021-01-11 23:22:11 +01:00 committed by GitHub
parent e0e5f2a7dd
commit 3db6bcf892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 342 additions and 295 deletions

View file

@ -4,19 +4,18 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
const testTitle = 'testContent'
const testContent = `---\ntitle: ${testTitle}\n---\nThis is some test content`
describe('Export', () => {
const testTitle = 'testContent'
const testContent = `---\ntitle: ${testTitle}\n---\nThis is some test content`
beforeEach(() => {
cy.visit('/n/test')
cy.get('.btn.active.btn-outline-secondary > i.fa-columns')
.should('exist')
cy.get('.CodeMirror textarea')
.type('{ctrl}a', { force: true })
.type('{backspace}')
cy.get('.CodeMirror textarea')
.type(testContent)
cy.get('.CodeMirror')
.click()
.get('textarea')
.fill(testContent)
})
it('Markdown', () => {
@ -28,27 +27,27 @@ describe('Export', () => {
.then((anchor) => (
new Cypress.Promise((resolve: any, _: any) => {
// Use XHR to get the blob that corresponds to the object URL.
const xhr = new XMLHttpRequest();
xhr.open('GET', anchor.prop('href'), true);
xhr.responseType = 'blob';
const xhr = new XMLHttpRequest()
xhr.open('GET', anchor.prop('href'), true)
xhr.responseType = 'blob'
// Once loaded, use FileReader to get the string back from the blob.
xhr.onload = () => {
if (xhr.status === 200) {
const blob = xhr.response;
const reader = new FileReader();
const blob = xhr.response
const reader = new FileReader()
reader.onload = () => {
// Once we have a string, resolve the promise to let
// the Cypress chain continue, e.g. to assert on the result.
resolve(reader.result);
};
reader.readAsText(blob);
resolve(reader.result)
}
reader.readAsText(blob)
}
};
xhr.send();
}
xhr.send()
})
))
// Now the regular Cypress assertions should work.
.should('equal', testContent);
.should('equal', testContent)
})
})