-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] round trip tests for doctype and xml declaration
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
packages/prosemirror-lwdita-demo/cypress/e2e/round-trip.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*! | ||
Copyright (C) 2020 Evolved Binary | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
describe('Round Trip', () => { | ||
it('should be able to round trip a document', () => { | ||
// set up the entry xdita | ||
const mockXML = `<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE topic PUBLIC "-//OASIS//DTD LIGHTWEIGHT DITA Topic//EN" "lw-topic.dtd"> | ||
<topic id="petal"> | ||
<title>What is Petal?</title> | ||
</topic> | ||
`; | ||
window.localStorage.setItem('file', mockXML); | ||
cy.visit('http://localhost:1234/') | ||
.get('#saveFile') | ||
.click() | ||
.readFile('cypress/downloads/Petal.xml') | ||
// compare the output to the input | ||
.should('equal', mockXML); | ||
}); | ||
|
||
it('should be able to round trip a document without doctype header', () => { | ||
// set up the entry xdita | ||
const mockXML = ` | ||
<topic id="petal"> | ||
<title>What is Petal?</title> | ||
</topic> | ||
`; | ||
// set up the default doctype header | ||
const doctype = `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE topic PUBLIC "-//OASIS//DTD LIGHTWEIGHT DITA Topic//EN" "lw-topic.dtd">`; | ||
window.localStorage.setItem('file', mockXML); | ||
cy.visit('http://localhost:1234/') | ||
.get('#saveFile') | ||
.click() | ||
.readFile('cypress/downloads/Petal.xml') | ||
// compare the output to the input | ||
.should('equal', doctype + mockXML); | ||
}); | ||
|
||
it('should be able to round trip a document with a custom doctype header', () => { | ||
// set up the entry xdita | ||
const mockXML = `<?xml version="1.4" encoding="UTF-8"?> | ||
<!DOCTYPE topic PUBLIC "-//OASIS//DTD Custom DITA Topic//EN" "custom.dtd"> | ||
<topic id="petal"> | ||
<title>What is Petal?</title> | ||
</topic> | ||
`; | ||
// set up the default doctype header | ||
window.localStorage.setItem('file', mockXML); | ||
cy.visit('http://localhost:1234/') | ||
.get('#saveFile') | ||
.click() | ||
.readFile('cypress/downloads/Petal.xml') | ||
// compare the output to the input | ||
.should('equal', mockXML); | ||
}); | ||
}); |