@@ -58,4 +58,40 @@ describe('gridstack utils', function() {
5858 } ) ;
5959 } ) ;
6060
61+ describe ( 'test createStylesheet/removeStylesheet' , function ( ) {
62+
63+ it ( 'should create/remove style DOM' , function ( ) {
64+ var _id = 'test-123' ;
65+
66+ utils . createStylesheet ( _id ) ;
67+
68+ var style = $ ( 'STYLE[data-gs-style-id=' + _id + ']' ) ;
69+
70+ expect ( style . size ( ) ) . toEqual ( 1 ) ;
71+ expect ( style . prop ( 'tagName' ) ) . toEqual ( 'STYLE' ) ;
72+
73+ utils . removeStylesheet ( _id )
74+
75+ style = $ ( 'STYLE[data-gs-style-id=' + _id + ']' ) ;
76+
77+ expect ( style . size ( ) ) . toEqual ( 0 ) ;
78+ } ) ;
79+
80+ } ) ;
81+
82+ describe ( 'test parseHeight' , function ( ) {
83+
84+ it ( 'should parse height value' , function ( ) {
85+ expect ( utils . parseHeight ( 12 ) ) . toEqual ( jasmine . objectContaining ( { height : 12 , unit : 'px' } ) ) ;
86+ expect ( utils . parseHeight ( '12px' ) ) . toEqual ( jasmine . objectContaining ( { height : 12 , unit : 'px' } ) ) ;
87+ expect ( utils . parseHeight ( '12.3px' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.3 , unit : 'px' } ) ) ;
88+ expect ( utils . parseHeight ( '12.3em' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.3 , unit : 'em' } ) ) ;
89+ expect ( utils . parseHeight ( '12.3rem' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.3 , unit : 'rem' } ) ) ;
90+ expect ( utils . parseHeight ( '12.3vh' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.3 , unit : 'vh' } ) ) ;
91+ expect ( utils . parseHeight ( '12.3vw' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.3 , unit : 'vw' } ) ) ;
92+ expect ( utils . parseHeight ( '12.5' ) ) . toEqual ( jasmine . objectContaining ( { height : 12.5 , unit : 'px' } ) ) ;
93+ expect ( function ( ) { utils . parseHeight ( '12.5 df' ) ; } ) . toThrowError ( 'Invalid height' ) ;
94+ } ) ;
95+
96+ } ) ;
6197} ) ;
0 commit comments