Skip to content

Commit

Permalink
more clear assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed Feb 4, 2024
1 parent 3462cfe commit 7744e6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/shapes/Text/StyledText.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FabricText } from './Text';
import { graphemeSplit } from '../../util/lang_string';

describe('setSelectionStyles', () => {
test('will set properties at the correct position', () => {
Expand Down Expand Up @@ -37,7 +38,7 @@ describe('setSelectionStyles', () => {
});

describe('toObject', () => {
it('Will serialize text with grpahemes in mind', () => {
it('Will serialize text with graphemes in mind', () => {
const text = new FabricText('🤩🤩\nHello', {
styles: {
1: {
Expand All @@ -51,5 +52,8 @@ describe('toObject', () => {
expect(serializedStyles).toEqual([
{ start: 2, end: 3, style: { fontSize: 40 } },
]);
expect(serializedStyles[0].start).toEqual(
graphemeSplit(text.textLines[0]).length
);
});
});

0 comments on commit 7744e6d

Please sign in to comment.