mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
62f7600aa4
refs: https://github.com/TryGhost/Team/issues/2390 Escapes each matched and non-matched segment of the post title in the admin search field, to make sure they're displayed in plain text but still have matches highlighted.
23 lines
724 B
JavaScript
23 lines
724 B
JavaScript
import {
|
|
describe,
|
|
it
|
|
} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {
|
|
highlightedText
|
|
} from 'ghost-admin/helpers/highlighted-text';
|
|
|
|
describe('Unit: Helper: highlighted-text', function () {
|
|
it('works', function () {
|
|
let result = highlightedText(['Test', 'e']);
|
|
expect(result).to.be.an('object');
|
|
expect(result.string).to.equal('T<span class="highlight">e</span>st');
|
|
});
|
|
|
|
it('escapes html', function () {
|
|
let result = highlightedText(['<script>alert("oops")</script>', 'oops']);
|
|
expect(result).to.be.an('object');
|
|
expect(result.string).to.equal('<script>alert("<span class="highlight">oops</span>")</script>');
|
|
});
|
|
});
|