@@ -1643,10 +1643,7 @@ describe('Test lib.js:', function() {
1643
1643
// this is what got us into trouble actually - d3 selections can
1644
1644
// contain non-nodes - say for example d3 selections! then they
1645
1645
// don't work correctly. But it makes a convenient test!
1646
- d3 . select ( 1 ) ,
1647
- // just showing what we actually do in this function: duck type
1648
- // using the `classed` method.
1649
- { classed : function ( v ) { return ! ! v ; } }
1646
+ d3 . select ( 1 )
1650
1647
] ;
1651
1648
1652
1649
yesSelections . forEach ( function ( v ) {
@@ -1675,28 +1672,25 @@ describe('Test lib.js:', function() {
1675
1672
var stashLogLevel ;
1676
1673
var stashOnGraphLogLevel ;
1677
1674
1678
- function consoleFn ( name , hasApply , messages ) {
1675
+ function consoleFn ( name , messages ) {
1679
1676
var out = function ( ) {
1680
- if ( hasApply ) expect ( this ) . toBe ( window . console ) ;
1681
1677
var args = [ ] ;
1682
1678
for ( var i = 0 ; i < arguments . length ; i ++ ) args . push ( arguments [ i ] ) ;
1683
1679
messages . push ( [ name , args ] ) ;
1684
1680
} ;
1685
1681
1686
- if ( ! hasApply ) out . apply = undefined ;
1687
-
1688
1682
return out ;
1689
1683
}
1690
1684
1691
- function mockConsole ( hasApply , hasTrace , hasError ) {
1685
+ function mockConsole ( ) {
1692
1686
var out = {
1693
1687
MESSAGES : [ ]
1694
1688
} ;
1695
- out . log = consoleFn ( 'log' , hasApply , out . MESSAGES ) ;
1689
+ out . log = consoleFn ( 'log' , out . MESSAGES ) ;
1696
1690
1697
- if ( hasError ) out . error = consoleFn ( 'error' , hasApply , out . MESSAGES ) ;
1691
+ out . error = consoleFn ( 'error' , out . MESSAGES ) ;
1698
1692
1699
- if ( hasTrace ) out . trace = consoleFn ( 'trace' , hasApply , out . MESSAGES ) ;
1693
+ out . trace = consoleFn ( 'trace' , out . MESSAGES ) ;
1700
1694
1701
1695
return out ;
1702
1696
}
@@ -1713,8 +1707,8 @@ describe('Test lib.js:', function() {
1713
1707
config . notifyOnLogging = stashOnGraphLogLevel ;
1714
1708
} ) ;
1715
1709
1716
- it ( 'emits one console message if apply is available ' , function ( ) {
1717
- var c = window . console = mockConsole ( true , true , true ) ;
1710
+ it ( 'emits one console message' , function ( ) {
1711
+ var c = window . console = mockConsole ( ) ;
1718
1712
config . logging = 2 ;
1719
1713
1720
1714
Lib . log ( 'tick' , 'tock' , 'tick' , 'tock' , 1 ) ;
@@ -1728,50 +1722,8 @@ describe('Test lib.js:', function() {
1728
1722
] ) ;
1729
1723
} ) ;
1730
1724
1731
- it ( 'falls back on console.log if no trace' , function ( ) {
1732
- var c = window . console = mockConsole ( true , false , true ) ;
1733
- config . logging = 2 ;
1734
-
1735
- Lib . log ( 'Hi' ) ;
1736
- Lib . warn ( 42 ) ;
1737
-
1738
- expect ( c . MESSAGES ) . toEqual ( [
1739
- [ 'log' , [ 'LOG:' , 'Hi' ] ] ,
1740
- [ 'log' , [ 'WARN:' , 42 ] ]
1741
- ] ) ;
1742
- } ) ;
1743
-
1744
- it ( 'falls back on separate calls if no apply' , function ( ) {
1745
- var c = window . console = mockConsole ( false , false , true ) ;
1746
- config . logging = 2 ;
1747
-
1748
- Lib . log ( 'tick' , 'tock' , 'tick' , 'tock' , 1 ) ;
1749
- Lib . warn ( 'I\'m' , 'a' , 'little' , 'cuckoo' , 'clock' , [ 1 , 2 ] ) ;
1750
- Lib . error ( 'cuckoo!' , 'cuckoo!!!' , { a : 1 , b : 2 } ) ;
1751
-
1752
- expect ( c . MESSAGES ) . toEqual ( [
1753
- [ 'log' , [ 'LOG:' ] ] ,
1754
- [ 'log' , [ 'tick' ] ] ,
1755
- [ 'log' , [ 'tock' ] ] ,
1756
- [ 'log' , [ 'tick' ] ] ,
1757
- [ 'log' , [ 'tock' ] ] ,
1758
- [ 'log' , [ 1 ] ] ,
1759
- [ 'log' , [ 'WARN:' ] ] ,
1760
- [ 'log' , [ 'I\'m' ] ] ,
1761
- [ 'log' , [ 'a' ] ] ,
1762
- [ 'log' , [ 'little' ] ] ,
1763
- [ 'log' , [ 'cuckoo' ] ] ,
1764
- [ 'log' , [ 'clock' ] ] ,
1765
- [ 'log' , [ [ 1 , 2 ] ] ] ,
1766
- [ 'error' , [ 'ERROR:' ] ] ,
1767
- [ 'error' , [ 'cuckoo!' ] ] ,
1768
- [ 'error' , [ 'cuckoo!!!' ] ] ,
1769
- [ 'error' , [ { a : 1 , b : 2 } ] ]
1770
- ] ) ;
1771
- } ) ;
1772
-
1773
1725
it ( 'omits .log at log level 1' , function ( ) {
1774
- var c = window . console = mockConsole ( true , true , true ) ;
1726
+ var c = window . console = mockConsole ( ) ;
1775
1727
config . logging = 1 ;
1776
1728
1777
1729
Lib . log ( 1 ) ;
@@ -1785,7 +1737,7 @@ describe('Test lib.js:', function() {
1785
1737
} ) ;
1786
1738
1787
1739
it ( 'logs nothing at log level 0' , function ( ) {
1788
- var c = window . console = mockConsole ( true , true , true ) ;
1740
+ var c = window . console = mockConsole ( ) ;
1789
1741
config . logging = 0 ;
1790
1742
1791
1743
Lib . log ( 1 ) ;
@@ -1795,22 +1747,6 @@ describe('Test lib.js:', function() {
1795
1747
expect ( c . MESSAGES ) . toEqual ( [ ] ) ;
1796
1748
} ) ;
1797
1749
1798
- it ( 'falls back on simple log if there is no console.error' , function ( ) {
1799
- // TODO
1800
-
1801
- var c = window . console = mockConsole ( true , true , false ) ;
1802
- config . logging = 2 ;
1803
-
1804
- Lib . error ( 'who are you' , 'who who... are you' , { a : 1 , b : 2 } ) ;
1805
-
1806
- expect ( c . MESSAGES ) . toEqual ( [
1807
- [ 'log' , [ 'ERROR:' ] ] ,
1808
- [ 'log' , [ 'who are you' ] ] ,
1809
- [ 'log' , [ 'who who... are you' ] ] ,
1810
- [ 'log' , [ { a : 1 , b : 2 } ] ]
1811
- ] ) ;
1812
- } ) ;
1813
-
1814
1750
describe ( 'should log message in notifier div in accordance notifyOnLogging config option' , function ( ) {
1815
1751
var query = '.notifier-note' ;
1816
1752
0 commit comments