@@ -1671,8 +1671,9 @@ describe('Test lib.js:', function() {
16711671 } ) ;
16721672
16731673 describe ( 'loggers' , function ( ) {
1674- var stashConsole ,
1675- stashLogLevel ;
1674+ var stashConsole ;
1675+ var stashLogLevel ;
1676+ var stashOnGraphLogLevel ;
16761677
16771678 function consoleFn ( name , hasApply , messages ) {
16781679 var out = function ( ) {
@@ -1703,11 +1704,13 @@ describe('Test lib.js:', function() {
17031704 beforeEach ( function ( ) {
17041705 stashConsole = window . console ;
17051706 stashLogLevel = config . logging ;
1707+ stashOnGraphLogLevel = config . notifyOnLogging ;
17061708 } ) ;
17071709
17081710 afterEach ( function ( ) {
17091711 window . console = stashConsole ;
17101712 config . logging = stashLogLevel ;
1713+ config . notifyOnLogging = stashOnGraphLogLevel ;
17111714 } ) ;
17121715
17131716 it ( 'emits one console message if apply is available' , function ( ) {
@@ -1807,6 +1810,50 @@ describe('Test lib.js:', function() {
18071810 [ 'log' , [ { a : 1 , b : 2 } ] ]
18081811 ] ) ;
18091812 } ) ;
1813+
1814+ describe ( 'should log message in notifier div in accordance notifyOnLogging config option' , function ( ) {
1815+ var query = '.notifier-note' ;
1816+
1817+ beforeEach ( function ( done ) {
1818+ d3 . selectAll ( query ) . each ( function ( ) {
1819+ d3 . select ( this ) . select ( 'button' ) . node ( ) . click ( ) ;
1820+ } ) ;
1821+ setTimeout ( done , 1000 ) ;
1822+ } ) ;
1823+
1824+ function _run ( exp ) {
1825+ config . logging = 0 ;
1826+
1827+ Lib . log ( 'log' ) ;
1828+ Lib . warn ( 'warn' ) ;
1829+ Lib . error ( 'error!' ) ;
1830+
1831+ var notes = d3 . selectAll ( query ) ;
1832+
1833+ expect ( notes . size ( ) ) . toBe ( exp . length , '# of notifier notes' ) ;
1834+
1835+ var actual = [ ] ;
1836+ notes . each ( function ( ) {
1837+ actual . push ( d3 . select ( this ) . select ( 'p' ) . text ( ) ) ;
1838+ } ) ;
1839+ expect ( actual ) . toEqual ( exp ) ;
1840+ }
1841+
1842+ it ( 'with level 2' , function ( ) {
1843+ config . notifyOnLogging = 2 ;
1844+ _run ( [ 'log' , 'warn' , 'error!' ] ) ;
1845+ } ) ;
1846+
1847+ it ( 'with level 1' , function ( ) {
1848+ config . notifyOnLogging = 1 ;
1849+ _run ( [ 'warn' , 'error!' ] ) ;
1850+ } ) ;
1851+
1852+ it ( 'with level 0' , function ( ) {
1853+ config . notifyOnLogging = 0 ;
1854+ _run ( [ ] ) ;
1855+ } ) ;
1856+ } ) ;
18101857 } ) ;
18111858
18121859 describe ( 'keyedContainer' , function ( ) {
0 commit comments