@@ -34,42 +34,6 @@ describe('<TagsSelector />', () => {
3434 expect ( screen . getByPlaceholderText ( 'Add tags to the URL' ) ) . toBeInTheDocument ( ) ;
3535 } ) ;
3636
37- it ( 'contains expected tags' , ( ) => {
38- setUp ( ) ;
39-
40- expect ( screen . getByText ( 'foo' ) ) . toBeInTheDocument ( ) ;
41- expect ( screen . getByText ( 'bar' ) ) . toBeInTheDocument ( ) ;
42- } ) ;
43-
44- it ( 'contains expected suggestions' , async ( ) => {
45- const { container, user } = setUp ( ) ;
46-
47- expect ( container . querySelector ( '.react-tags__listbox' ) ) . not . toBeInTheDocument ( ) ;
48- expect ( screen . queryByText ( 'baz' ) ) . not . toBeInTheDocument ( ) ;
49-
50- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , 'ba' ) ;
51-
52- expect ( container . querySelector ( '.react-tags__listbox' ) ) . toBeInTheDocument ( ) ;
53- expect ( screen . getByText ( 'baz' ) ) . toBeInTheDocument ( ) ;
54- } ) ;
55-
56- it ( 'limits the amount of suggestions' , async ( ) => {
57- const { user } = setUp ( { allTags : [ 'foo' , 'foo1' , 'foo2' , 'foo3' , 'foo4' , 'foo5' , 'foo6' , 'foo7' ] } ) ;
58-
59- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , 'fo' ) ;
60-
61- // First results are in the document
62- expect ( screen . getByText ( 'foo' ) ) . toBeInTheDocument ( ) ;
63- expect ( screen . getByText ( 'foo1' ) ) . toBeInTheDocument ( ) ;
64- expect ( screen . getByText ( 'foo2' ) ) . toBeInTheDocument ( ) ;
65- expect ( screen . getByText ( 'foo3' ) ) . toBeInTheDocument ( ) ;
66- expect ( screen . getByText ( 'foo4' ) ) . toBeInTheDocument ( ) ;
67- expect ( screen . getByText ( 'foo5' ) ) . toBeInTheDocument ( ) ;
68- // While the last ones are not
69- expect ( screen . queryByText ( 'foo6' ) ) . not . toBeInTheDocument ( ) ;
70- expect ( screen . queryByText ( 'foo7' ) ) . not . toBeInTheDocument ( ) ;
71- } ) ;
72-
7337 it . each ( [
7438 [ 'The-New-Tag' , [ ...tags , 'the-new-tag' ] ] ,
7539 [ 'AnOTH er tag ' , [ ...tags , 'anoth-er-tag' ] ] ,
@@ -82,51 +46,4 @@ describe('<TagsSelector />', () => {
8246 await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , '{Enter}' ) ;
8347 expect ( onChange ) . toHaveBeenCalledWith ( expectedTags ) ;
8448 } ) ;
85-
86- it ( 'splits tags when several comma-separated ones are pasted' , async ( ) => {
87- const { user } = setUp ( ) ;
88-
89- expect ( onChange ) . not . toHaveBeenCalled ( ) ;
90- await user . click ( screen . getByPlaceholderText ( 'Add tags to the URL' ) ) ;
91- await user . paste ( 'comma,separated,tags' ) ;
92- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , '{Enter}' ) ;
93- expect ( onChange ) . toHaveBeenCalledWith ( [ ...tags , 'comma' , 'separated' , 'tags' ] ) ;
94- } ) ;
95-
96- it . each ( [
97- [ 'foo' , 'bar' ] ,
98- [ 'bar' , 'foo' ] ,
99- ] ) ( 'invokes onChange when tags are deleted' , async ( removedLabel , expected ) => {
100- const { user } = setUp ( ) ;
101-
102- await user . click ( screen . getByLabelText ( `Remove ${ removedLabel } ` ) ) ;
103- expect ( onChange ) . toHaveBeenCalledWith ( [ expected ] ) ;
104- } ) ;
105-
106- it ( 'displays "Add tag" option for new tags' , async ( ) => {
107- const { user } = setUp ( ) ;
108-
109- expect ( screen . queryByText ( / ^ A d d " / ) ) . not . toBeInTheDocument ( ) ;
110- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , 'new-tag' ) ;
111- expect ( screen . getByText ( / ^ A d d " / ) ) . toBeInTheDocument ( ) ;
112- } ) ;
113-
114- it ( 'displays "Tag not found" for unknown tags when add is not allowed' , async ( ) => {
115- const { user } = setUp ( { allowNew : false } ) ;
116-
117- expect ( screen . queryByText ( 'Tag not found' ) ) . not . toBeInTheDocument ( ) ;
118- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , 'not-found-tag' ) ;
119- expect ( screen . getByText ( 'Tag not found' ) ) . toBeInTheDocument ( ) ;
120- } ) ;
121-
122- it . each ( [
123- [ 'startsWith' as TagFilteringMode , [ 'foo' , 'foobar' ] ] ,
124- [ 'includes' as TagFilteringMode , [ 'foo' , 'barfoo' , 'foobar' ] ] ,
125- ] ) ( 'filters suggestions with different algorithm based on filtering mode' , async ( tagFilteringMode , expectedTags ) => {
126- const { user } = setUp ( { tagFilteringMode, allTags : [ 'foo' , 'barfoo' , 'foobar' ] } ) ;
127-
128- await user . type ( screen . getByPlaceholderText ( 'Add tags to the URL' ) , ' Foo' ) ;
129-
130- expectedTags . forEach ( ( tag ) => expect ( screen . getByText ( tag ) ) . toBeInTheDocument ( ) ) ;
131- } ) ;
13249} ) ;
0 commit comments