@@ -3,19 +3,34 @@ const SelectionInfoRegistry = require('../../lib/selection-info-registry');
33
44suite ( 'SelectionInfoRegistry' , ( ) => {
55
6- test ( 'it saves a given text selection information with a given key' , ( ) => {
6+ test ( 'it saves selected text with a given key' , ( ) => {
77 const selectionInfoRegistry = new SelectionInfoRegistry ( ) ;
8- selectionInfoRegistry . set ( 'KEY' , {
9- text : 'TEXT' ,
10- fileName : 'FILE_NAME' ,
11- lineRanges : 'LINE_RANGES' ,
12- '..' : '..'
13- } ) ;
14- expect ( selectionInfoRegistry . get ( 'KEY' ) ) . to . eql ( {
15- text : 'TEXT' ,
16- fileName : 'FILE_NAME' ,
17- lineRanges : 'LINE_RANGES'
18- } ) ;
8+ selectionInfoRegistry . set ( 'KEY' , { text : 'TEXT' } ) ;
9+ expect ( selectionInfoRegistry . get ( 'KEY' ) . text ) . to . include ( 'TEXT' ) ;
10+ } ) ;
11+
12+ test ( 'it saves the file name of the selected text with a given key' , ( ) => {
13+ const selectionInfoRegistry = new SelectionInfoRegistry ( ) ;
14+ selectionInfoRegistry . set ( 'KEY' , { fileName : 'FILE_NAME' } ) ;
15+ expect ( selectionInfoRegistry . get ( 'KEY' ) . fileName ) . to . eql ( 'FILE_NAME' ) ;
16+ } ) ;
17+
18+ test ( 'it saves the line ranges of the selected text with a given key' , ( ) => {
19+ const selectionInfoRegistry = new SelectionInfoRegistry ( ) ;
20+ selectionInfoRegistry . set ( 'KEY' , { lineRanges : 'LINE_RANGES' } ) ;
21+ expect ( selectionInfoRegistry . get ( 'KEY' ) . lineRanges ) . to . eql ( 'LINE_RANGES' ) ;
22+ } ) ;
23+
24+ test ( 'it ignores other attributes given in text info' , ( ) => {
25+ const selectionInfoRegistry = new SelectionInfoRegistry ( ) ;
26+ selectionInfoRegistry . set ( 'KEY' , { SOMETHING : '..' } ) ;
27+ expect ( selectionInfoRegistry . get ( 'KEY' ) . SOMETHING ) . to . be . undefined ;
28+ } ) ;
29+
30+ test ( 'it sets an empty list for line ranges if they are not given' , ( ) => {
31+ const selectionInfoRegistry = new SelectionInfoRegistry ( ) ;
32+ selectionInfoRegistry . set ( 'KEY' , { } ) ;
33+ expect ( selectionInfoRegistry . get ( 'KEY' ) . lineRanges ) . to . eql ( [ ] ) ;
1934 } ) ;
2035
2136} ) ;
0 commit comments