mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 10:10:08 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -5,13 +5,13 @@ const MODULE_PATH = require('path').join(
|
||||
'../../../../app/src/Features/Helpers/SafeHTMLSubstitution.js'
|
||||
)
|
||||
|
||||
describe('SafeHTMLSubstitution', function() {
|
||||
describe('SafeHTMLSubstitution', function () {
|
||||
let SafeHTMLSubstitution
|
||||
before(function() {
|
||||
before(function () {
|
||||
SafeHTMLSubstitution = SandboxedModule.require(MODULE_PATH)
|
||||
})
|
||||
|
||||
describe('SPLIT_REGEX', function() {
|
||||
describe('SPLIT_REGEX', function () {
|
||||
const CASES = {
|
||||
'PRE<0>INNER</0>POST': ['PRE', '0', 'INNER', 'POST'],
|
||||
'<0>INNER</0>': ['', '0', 'INNER', ''],
|
||||
@@ -21,7 +21,7 @@ describe('SafeHTMLSubstitution', function() {
|
||||
'PLAIN TEXT': ['PLAIN TEXT']
|
||||
}
|
||||
Object.entries(CASES).forEach(([input, output]) => {
|
||||
it(`should parse "${input}" as expected`, function() {
|
||||
it(`should parse "${input}" as expected`, function () {
|
||||
expect(input.split(SafeHTMLSubstitution.SPLIT_REGEX)).to.deep.equal(
|
||||
output
|
||||
)
|
||||
@@ -29,27 +29,27 @@ describe('SafeHTMLSubstitution', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('render', function() {
|
||||
describe('substitution', function() {
|
||||
it('should substitute a single component', function() {
|
||||
describe('render', function () {
|
||||
describe('substitution', function () {
|
||||
it('should substitute a single component', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>good</0>', [{ name: 'b' }])
|
||||
).to.equal('<b>good</b>')
|
||||
})
|
||||
|
||||
it('should substitute a single component as string', function() {
|
||||
it('should substitute a single component as string', function () {
|
||||
expect(SafeHTMLSubstitution.render('<0>good</0>', ['b'])).to.equal(
|
||||
'<b>good</b>'
|
||||
)
|
||||
})
|
||||
|
||||
it('should substitute a single component twice', function() {
|
||||
it('should substitute a single component twice', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>one</0><0>two</0>', [{ name: 'b' }])
|
||||
).to.equal('<b>one</b><b>two</b>')
|
||||
})
|
||||
|
||||
it('should substitute two components', function() {
|
||||
it('should substitute two components', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>one</0><1>two</1>', [
|
||||
{ name: 'b' },
|
||||
@@ -58,7 +58,7 @@ describe('SafeHTMLSubstitution', function() {
|
||||
).to.equal('<b>one</b><i>two</i>')
|
||||
})
|
||||
|
||||
it('should substitute a single component with a class', function() {
|
||||
it('should substitute a single component with a class', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>text</0>', [
|
||||
{
|
||||
@@ -71,7 +71,7 @@ describe('SafeHTMLSubstitution', function() {
|
||||
).to.equal('<b class="magic">text</b>')
|
||||
})
|
||||
|
||||
it('should substitute two nested components', function() {
|
||||
it('should substitute two nested components', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0><1>nested</1></0>', [
|
||||
{ name: 'b' },
|
||||
@@ -80,7 +80,7 @@ describe('SafeHTMLSubstitution', function() {
|
||||
).to.equal('<b><i>nested</i></b>')
|
||||
})
|
||||
|
||||
it('should handle links', function() {
|
||||
it('should handle links', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>Go to Login</0>', [
|
||||
{ name: 'a', attrs: { href: 'https://www.overleaf.com/login' } }
|
||||
@@ -88,7 +88,7 @@ describe('SafeHTMLSubstitution', function() {
|
||||
).to.equal('<a href="https://www.overleaf.com/login">Go to Login</a>')
|
||||
})
|
||||
|
||||
it('should not complain about too many components', function() {
|
||||
it('should not complain about too many components', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>good</0>', [
|
||||
{ name: 'b' },
|
||||
@@ -99,52 +99,52 @@ describe('SafeHTMLSubstitution', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('pug.escape', function() {
|
||||
it('should handle plain text', function() {
|
||||
describe('pug.escape', function () {
|
||||
it('should handle plain text', function () {
|
||||
expect(SafeHTMLSubstitution.render('plain text')).to.equal('plain text')
|
||||
})
|
||||
|
||||
it('should keep a simple string delimiter', function() {
|
||||
it('should keep a simple string delimiter', function () {
|
||||
expect(SafeHTMLSubstitution.render("'")).to.equal(`'`)
|
||||
})
|
||||
|
||||
it('should escape double quotes', function() {
|
||||
it('should escape double quotes', function () {
|
||||
expect(SafeHTMLSubstitution.render('"')).to.equal(`"`)
|
||||
})
|
||||
|
||||
it('should escape &', function() {
|
||||
it('should escape &', function () {
|
||||
expect(SafeHTMLSubstitution.render('&')).to.equal(`&`)
|
||||
})
|
||||
|
||||
it('should escape <', function() {
|
||||
it('should escape <', function () {
|
||||
expect(SafeHTMLSubstitution.render('<')).to.equal(`<`)
|
||||
})
|
||||
|
||||
it('should escape >', function() {
|
||||
it('should escape >', function () {
|
||||
expect(SafeHTMLSubstitution.render('>')).to.equal(`>`)
|
||||
})
|
||||
|
||||
it('should escape html', function() {
|
||||
it('should escape html', function () {
|
||||
expect(SafeHTMLSubstitution.render('<b>bad</b>')).to.equal(
|
||||
'<b>bad</b>'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('escape around substitutions', function() {
|
||||
it('should escape text inside a component', function() {
|
||||
describe('escape around substitutions', function () {
|
||||
it('should escape text inside a component', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0><i>inner</i></0>', [{ name: 'b' }])
|
||||
).to.equal('<b><i>inner</i></b>')
|
||||
})
|
||||
|
||||
it('should escape text in front of a component', function() {
|
||||
it('should escape text in front of a component', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<i>PRE</i><0>inner</0>', [{ name: 'b' }])
|
||||
).to.equal('<i>PRE</i><b>inner</b>')
|
||||
})
|
||||
|
||||
it('should escape text after of a component', function() {
|
||||
it('should escape text after of a component', function () {
|
||||
expect(
|
||||
SafeHTMLSubstitution.render('<0>inner</0><i>POST</i>', [
|
||||
{ name: 'b' }
|
||||
|
||||
Reference in New Issue
Block a user