-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
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
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,62 @@ | ||
import {expect} from 'chai'; | ||
import {translateEntitiesAndCharacterReferences, XML_ENTITIES} from '../../externals/tXml.js' | ||
|
||
describe('tXml', () => { | ||
|
||
describe('translateEntitiesAndCharacterReferences', () => { | ||
|
||
it('should not change string without XML entities', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634')).to.be.equal('PT634') | ||
}) | ||
|
||
it('should translate general entity amp', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634&')).to.be.equal('PT634&') | ||
}) | ||
|
||
it('should translate general entity lt', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634<')).to.be.equal('PT634<') | ||
}) | ||
|
||
it('should translate general entity gt', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634>')).to.be.equal('PT634>') | ||
}) | ||
|
||
it('should translate general entity apos', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634'')).to.be.equal('PT634\'') | ||
}) | ||
|
||
it('should translate general entity quot', () => { | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, 'PT634"')).to.be.equal('PT634"') | ||
}) | ||
|
||
it('should translate all general entities', () => { | ||
const input = '& > < " ''; | ||
const expectedOutput = '& > < " \''; | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, input)).to.be.equal(expectedOutput) | ||
}) | ||
|
||
it('should correctly translate decimal character references', () => { | ||
const input = 'A B C'; | ||
const expectedOutput = 'A B C'; | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, input)).to.be.equal(expectedOutput) | ||
}) | ||
|
||
it('should correctly translate hexadecimal character references', () => { | ||
const input = 'A B C'; | ||
const expectedOutput = 'A B C'; | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, input)).to.be.equal(expectedOutput) | ||
}) | ||
|
||
it('should correctly translate character references mixed with other text', () => { | ||
const input = 'This is a test: A B C'; | ||
const expectedOutput = 'This is a test: A B C'; | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, input)).to.be.equal(expectedOutput) | ||
}) | ||
|
||
it('should correctly translate character references mixed with general entities and other text', () => { | ||
const input = 'This is a test: A B C & > < " ''; | ||
const expectedOutput = 'This is a test: A B C & > < " \''; | ||
expect(translateEntitiesAndCharacterReferences(XML_ENTITIES, input)).to.be.equal(expectedOutput) | ||
}) | ||
}) | ||
}) |