@@ -12,7 +12,7 @@ describe('filter-input', function() {
1212 } )
1313
1414 describe ( 'after tree insertion' , function ( ) {
15- let filterInput , input , list , emptyState
15+ let filterInput , input , list , emptyState , newItem
1616 beforeEach ( function ( ) {
1717 document . body . innerHTML = `
1818 <filter-input aria-owns="robots">
@@ -29,20 +29,40 @@ describe('filter-input', function() {
2929 <li>BB-8</li>
3030 </ul>
3131 <p data-filter-empty-state hidden>0 robots found.</p>
32+ <form data-filter-new-item hidden>
33+ <button data-filter-new-item-value>Create "<span data-filter-new-item-text></span>"</button>
34+ </form>
3235 </div>
3336 `
3437
3538 filterInput = document . querySelector ( 'filter-input' )
3639 input = filterInput . querySelector ( 'input' )
3740 list = document . querySelector ( '[data-filter-list]' )
3841 emptyState = document . querySelector ( '[data-filter-empty-state]' )
42+ newItem = document . querySelector ( '[data-filter-new-item]' )
3943 } )
4044
4145 afterEach ( function ( ) {
4246 document . body . innerHTML = ''
4347 } )
4448
45- it ( 'filters' , async function ( ) {
49+ it ( 'filters and toggles new item form' , async function ( ) {
50+ const listener = once ( 'filter-input-updated' )
51+ changeValue ( input , 'hu' )
52+ const customEvent = await listener
53+ assert . equal ( customEvent . detail . count , 1 )
54+ assert . equal ( customEvent . detail . total , 4 )
55+
56+ changeValue ( input , 'boom' )
57+ assert . notOk ( newItem . hidden , 'New item form should be shown' )
58+ assert . equal ( newItem . querySelector ( '[data-filter-new-item-value]' ) . value , 'boom' )
59+ assert . equal ( newItem . querySelector ( '[data-filter-new-item-text]' ) . textContent , 'boom' )
60+ } )
61+
62+ it ( 'filters and toggles blankslate' , async function ( ) {
63+ // Remove new item form, which is prioritized over blankslate
64+ newItem . remove ( )
65+
4666 const listener = once ( 'filter-input-updated' )
4767 changeValue ( input , 'hu' )
4868 const customEvent = await listener
0 commit comments