import { describe, it } from '@ephox/bedrock-client'; import { Unicode } from '@ephox/katamari'; import { SugarElement } from '@ephox/sugar'; import { assert } from 'chai'; import * as DomTextZones from 'ephox/robin/api/dom/DomTextZones'; import { ZoneViewports } from 'ephox/robin/api/general/ZoneViewports'; describe('browser.robin.zone.EntityTest', () => { it('TINY-7908: Soft hyphens are not treated as a word boundary', () => { const content = SugarElement.fromHtml('
some plain words and a hy­phenated word
'); const zones = DomTextZones.single(content, 'en-US', ZoneViewports.anything()); const rawZones = zones.zones.map((z) => ({ lang: z.lang, words: z.words.map((w) => w.word) })); assert.deepEqual(rawZones, [ { lang: 'en-US', words: [ 'some', 'plain', 'words', 'and', 'a', `hy${Unicode.softHyphen}phenated`, 'word' ] } ]); }); it('Zero width spaces are not treated as a word boundary', () => { const content = SugarElement.fromHtml(`
some plain words with somespace
`); const zones = DomTextZones.single(content, 'en-US', ZoneViewports.anything()); const rawZones = zones.zones.map((z) => ({ lang: z.lang, words: z.words.map((w) => w.word) })); assert.deepEqual(rawZones, [ { lang: 'en-US', words: [ 'some', 'plain', 'words', 'with', `some${Unicode.zeroWidth}space` ] } ]); }); it('Non breaking spaces are treated as a word boundary', () => { const content = SugarElement.fromHtml(`
some plain words with some space
`); const zones = DomTextZones.single(content, 'en-US', ZoneViewports.anything()); const rawZones = zones.zones.map((z) => ({ lang: z.lang, words: z.words.map((w) => w.word) })); assert.deepEqual(rawZones, [ { lang: 'en-US', words: [ 'some', 'plain', 'words', 'with', 'some', 'space' ] } ]); }); });