File tree Expand file tree Collapse file tree
entry_types/scrolled/package Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -364,6 +364,61 @@ describe('StyleListInputView', () => {
364364 expect ( model . has ( 'marginTop' ) ) . toBe ( false ) ;
365365 } ) ;
366366
367+ it ( 'applies allUsed class when all styles are in use' , ( ) => {
368+ const types = {
369+ blur : {
370+ label : 'Blur' ,
371+ minValue : 0 ,
372+ maxValue : 100 ,
373+ defaultValue : 50 ,
374+ kind : 'filter' ,
375+ inputType : 'slider'
376+ }
377+ } ;
378+ const model = new Backbone . Model ( { styles : [
379+ { name : 'blur' , value : 30 }
380+ ] } ) ;
381+
382+ const view = new StyleListInputView ( {
383+ model,
384+ propertyName : 'styles' ,
385+ types,
386+ translationKeyPrefix : 'pageflow_scrolled.editor.style_list_input'
387+ } ) ;
388+ render ( view ) ;
389+
390+ expect ( view . el ) . toHaveClass ( styles . allUsed ) ;
391+ } ) ;
392+
393+ it ( 'removes allUsed class when style is removed' , async ( ) => {
394+ const types = {
395+ blur : {
396+ label : 'Blur' ,
397+ minValue : 0 ,
398+ maxValue : 100 ,
399+ defaultValue : 50 ,
400+ kind : 'filter' ,
401+ inputType : 'slider'
402+ }
403+ } ;
404+ const model = new Backbone . Model ( { styles : [
405+ { name : 'blur' , value : 30 }
406+ ] } ) ;
407+
408+ const view = new StyleListInputView ( {
409+ model,
410+ propertyName : 'styles' ,
411+ types,
412+ translationKeyPrefix : 'pageflow_scrolled.editor.style_list_input'
413+ } ) ;
414+
415+ const user = userEvent . setup ( ) ;
416+ const { getByRole} = render ( view ) ;
417+ await user . click ( getByRole ( 'button' , { name : 'Remove style' } ) ) ;
418+
419+ expect ( view . el ) . not . toHaveClass ( styles . allUsed ) ;
420+ } ) ;
421+
367422 it ( 'allows removing styles' , async ( ) => {
368423 const types = {
369424 blur : {
Original file line number Diff line number Diff line change @@ -100,10 +100,11 @@ export const StyleListInputView = Marionette.ItemView.extend({
100100 } ) ) ;
101101
102102 const update = ( ) =>
103- this . $el . toggleClass ( styles . allUsed , unusedStyles . length === 0 ) ;
103+ this . $el . toggleClass ( styles . allUsed ,
104+ unusedStyles . where ( { hidden : false } ) . length === 0 ) ;
104105
105106 update ( ) ;
106- this . listenTo ( unusedStyles , 'add remove ' , update ) ;
107+ this . listenTo ( unusedStyles , 'change:hidden ' , update ) ;
107108 }
108109} ) ;
109110
You can’t perform that action at this time.
0 commit comments