Skip to content

Commit

Permalink
Add further tests for getters
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Roeller committed Jul 31, 2020
1 parent d860659 commit 172618f
Showing 1 changed file with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { renderEditor } from 'jest-remirror';

import { isExtensionValid } from '@remirror/testing';

import { AnnotationExtension } from '..';
import { Annotation, AnnotationExtension } from '..';
import { AnnotationOptions } from '../types';

test('is valid', () => {
Expand Down Expand Up @@ -151,7 +151,53 @@ describe('getters', () => {
]);
});

// #getAnnotationsAt (where there are annotations)
// #getAnnotationsAt (where there aren't annotations)
// Keep fields from custom annotation type
it.skip('#getAnnotationsAt', () => {
add(doc(p('An <start>important<end> note')));
commands.addAnnotation({ id: '1' });

expect(extension.getAnnotationsAt(view.state, 5)).toEqual([
{
id: '1',
from: 3,
to: 13,
text: 'important',
},
]);
});

it.skip('#getAnnotationsAt (unannotated)', () => {
add(doc(p('An <start>important<end> note')));
commands.addAnnotation({ id: '1' });

expect(extension.getAnnotationsAt(view.state, 2)).toEqual([]);
});
});

describe('custom annotation type', () => {
interface MyAnnotation extends Annotation {
tag: string;
}

const extension = new AnnotationExtension<MyAnnotation>();
const {
add,
nodes: { p, doc },
commands,
view,
} = renderEditor([extension]);

it.skip('#getAnnotations', () => {
add(doc(p('<start>Hello<end>')));
commands.addAnnotation({ id: '1', tag: 'tag' });

expect(extension.getAnnotations(view.state)).toEqual([
{
id: '1',
from: 1,
to: 5,
tag: 'tag',
text: 'Hello',
},
]);
});
});

0 comments on commit 172618f

Please sign in to comment.