Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitm@lovullo.com>2016-04-04 23:59:57 -0400
committerMike Gerwitz <gerwitm@lovullo.com>2016-04-04 23:59:57 -0400
commitbefca68110a96516f466699a02aa2c6f486ad796 (patch)
treefe2b430694d6f3c85ac90651de67829ea491239b /test
parente1c2194962f16b8d4865b2f5dce71c1cddd3b790 (diff)
downloadliza-befca68110a96516f466699a02aa2c6f486ad796.tar.gz
liza-befca68110a96516f466699a02aa2c6f486ad796.tar.bz2
liza-befca68110a96516f466699a02aa2c6f486ad796.zip
Extract NaFieldStyler show/hide actions into protected methods
* src/ui/styler/NaFieldStyler.js (showField, hideField): Added * test/ui/styler/NaFieldStyler.js: Added respective tests
Diffstat (limited to 'test')
-rw-r--r--test/ui/styler/NaFieldStylerTest.js134
1 files changed, 78 insertions, 56 deletions
diff --git a/test/ui/styler/NaFieldStylerTest.js b/test/ui/styler/NaFieldStylerTest.js
index 26c7431..ae046aa 100644
--- a/test/ui/styler/NaFieldStylerTest.js
+++ b/test/ui/styler/NaFieldStylerTest.js
@@ -27,47 +27,84 @@ var styler = require( '../../../' ).ui.styler,
describe( 'ui.styler.NaFieldStyler', function()
{
- describe( '#getId', function()
+ function testApplyHidden()
{
- it( 'returns unique identifier', function()
+ var element = { className: '' },
+ r1 = { className: '' },
+ r2 = { className: '' },
+ row = [ r1, r2 ];
+
+ Sut().applyStyle( getStubField( element ), element, row );
+
+ [ element, r1, r2 ].forEach( function( ele )
{
- expect( Sut().getId() ).to.equal( 'na' );
+ expect( ele.className ).to.match( /\bhidden\b/ );
} );
- } );
+ }
- describe( '#applyStyle', function()
+ function testApplyClear()
{
- it( 'sets hidden class on all elements', function()
+ var element = { style: 'foo' },
+ r1 = { style: 'foo' },
+ r2 = { style: 'foo' },
+ row = [ r1, r2 ];
+
+ Sut().applyStyle( getStubField( element ), element, row );
+
+ [ element, r1, r2 ].forEach( function( ele )
{
- var element = { className: '' },
- r1 = { className: '' },
- r2 = { className: '' },
- row = [ r1, r2 ];
+ expect( ele.style ).to.equal( '' );
+ } );
+ }
- Sut().applyStyle( getStubField( element ), element, row );
- [ element, r1, r2 ].forEach( function( ele )
- {
- expect( ele.className ).to.match( /\bhidden\b/ );
- } );
+ function testRevokeHidden()
+ {
+ var element = { className: 'foo hidden' },
+ r1 = { className: 'foo hidden' },
+ r2 = { className: 'foo hidden' },
+ row = [ r1, r2 ];
+
+ Sut().revokeStyle( getStubField( element ), element, row );
+
+ [ element, r1, r2 ].forEach( function( ele )
+ {
+ expect( ele.className ).to.not.match( /\bhidden\b/ );
+ expect( ele.className ).to.match( /foo/ );
} );
+ }
+
+
+ function testRevokeStyle()
+ {
+ var element = { style: 'foo' },
+ r1 = { style: 'foo' },
+ r2 = { style: 'foo' },
+ row = [ r1, r2 ];
+ Sut().revokeStyle( getStubField( element ), element, row );
- it( 'clears style on all elements', function()
+ [ element, r1, r2 ].forEach( function( ele )
{
- var element = { style: 'foo' },
- r1 = { style: 'foo' },
- r2 = { style: 'foo' },
- row = [ r1, r2 ];
+ expect( ele.style ).to.equal( 'foo' );
+ } );
+ }
- Sut().applyStyle( getStubField( element ), element, row );
- [ element, r1, r2 ].forEach( function( ele )
- {
- expect( ele.style ).to.equal( '' );
- } );
+ describe( '#getId', function()
+ {
+ it( 'returns unique identifier', function()
+ {
+ expect( Sut().getId() ).to.equal( 'na' );
} );
+ } );
+
+
+ describe( '#applyStyle', function()
+ {
+ it( 'sets hidden class on all elements', testApplyHidden );
+ it( 'clears style on all elements', testApplyClear );
it( 'does not set class on subfield parents', function()
@@ -142,37 +179,8 @@ describe( 'ui.styler.NaFieldStyler', function()
describe( '#revokeStyle', function()
{
- it( 'removes hidden class on all elements', function()
- {
- var element = { className: 'foo hidden' },
- r1 = { className: 'foo hidden' },
- r2 = { className: 'foo hidden' },
- row = [ r1, r2 ];
-
- Sut().revokeStyle( getStubField( element ), element, row );
-
- [ element, r1, r2 ].forEach( function( ele )
- {
- expect( ele.className ).to.not.match( /\bhidden\b/ );
- expect( ele.className ).to.match( /foo/ );
- } );
- } );
-
-
- it( 'does not clear style on all elements', function()
- {
- var element = { style: 'foo' },
- r1 = { style: 'foo' },
- r2 = { style: 'foo' },
- row = [ r1, r2 ];
-
- Sut().revokeStyle( getStubField( element ), element, row );
-
- [ element, r1, r2 ].forEach( function( ele )
- {
- expect( ele.style ).to.equal( 'foo' );
- } );
- } );
+ it( 'removes hidden class on all elements', testRevokeHidden );
+ it( 'does not clear style on all elements', testRevokeStyle );
it( 'does not remove hidden class on subfield parents', function()
@@ -274,6 +282,20 @@ describe( 'ui.styler.NaFieldStyler', function()
.to.be.false;
} );
} );
+
+
+ describe( '#hideField', function()
+ {
+ it( 'sets hidden class on all elements', testApplyHidden );
+ it( 'clears style on all elements', testApplyClear );
+ } );
+
+
+ describe( '#showField', function()
+ {
+ it( 'removes hidden class on all elements', testRevokeHidden );
+ it( 'does not clear style on all elements', testRevokeStyle );
+ } );
} );
} );