@@ -2181,52 +2181,54 @@ describe('Test lib.js:', function() {
21812181 } ) ;
21822182
21832183 describe ( 'hovertemplateString' , function ( ) {
2184+ var locale = false ;
21842185 it ( 'evaluates attributes' , function ( ) {
2185- expect ( Lib . hovertemplateString ( 'foo %{bar}' , { } , { bar : 'baz' } ) ) . toEqual ( 'foo baz' ) ;
2186+ expect ( Lib . hovertemplateString ( 'foo %{bar}' , { } , locale , { bar : 'baz' } ) ) . toEqual ( 'foo baz' ) ;
21862187 } ) ;
21872188
21882189 it ( 'evaluates attributes with a dot in their name' , function ( ) {
2189- expect ( Lib . hovertemplateString ( '%{marker.size}' , { } , { 'marker.size' : 12 } , { marker : { size : 14 } } ) ) . toEqual ( '12' ) ;
2190+ expect ( Lib . hovertemplateString ( '%{marker.size}' , { } , locale , { 'marker.size' : 12 } , { marker : { size : 14 } } ) ) . toEqual ( '12' ) ;
21902191 } ) ;
21912192
21922193 it ( 'evaluates nested properties' , function ( ) {
2193- expect ( Lib . hovertemplateString ( 'foo %{bar.baz}' , { } , { bar : { baz : 'asdf' } } ) ) . toEqual ( 'foo asdf' ) ;
2194+ expect ( Lib . hovertemplateString ( 'foo %{bar.baz}' , { } , locale , { bar : { baz : 'asdf' } } ) ) . toEqual ( 'foo asdf' ) ;
21942195 } ) ;
21952196
21962197 it ( 'evaluates array nested properties' , function ( ) {
2197- expect ( Lib . hovertemplateString ( 'foo %{bar[0].baz}' , { } , { bar : [ { baz : 'asdf' } ] } ) ) . toEqual ( 'foo asdf' ) ;
2198+ expect ( Lib . hovertemplateString ( 'foo %{bar[0].baz}' , { } , locale , { bar : [ { baz : 'asdf' } ] } ) ) . toEqual ( 'foo asdf' ) ;
21982199 } ) ;
21992200
22002201 it ( 'subtitutes multiple matches' , function ( ) {
2201- expect ( Lib . hovertemplateString ( 'foo %{group} %{trace}' , { } , { group : 'asdf' , trace : 'jkl;' } ) ) . toEqual ( 'foo asdf jkl;' ) ;
2202+ expect ( Lib . hovertemplateString ( 'foo %{group} %{trace}' , { } , locale , { group : 'asdf' , trace : 'jkl;' } ) ) . toEqual ( 'foo asdf jkl;' ) ;
22022203 } ) ;
22032204
22042205 it ( 'replaces missing matches with template string' , function ( ) {
2205- expect ( Lib . hovertemplateString ( 'foo %{group} %{trace}' , { } , { group : 1 } ) ) . toEqual ( 'foo 1 %{trace}' ) ;
2206+ expect ( Lib . hovertemplateString ( 'foo %{group} %{trace}' , { } , locale , { group : 1 } ) ) . toEqual ( 'foo 1 %{trace}' ) ;
22062207 } ) ;
22072208
22082209 it ( 'uses the value from the first object with the specified key' , function ( ) {
22092210 var obj1 = { a : 'first' } ;
22102211 var obj2 = { a : 'second' , foo : { bar : 'bar' } } ;
22112212
22122213 // Simple key
2213- expect ( Lib . hovertemplateString ( 'foo %{a}' , { } , obj1 , obj2 ) ) . toEqual ( 'foo first' ) ;
2214- expect ( Lib . hovertemplateString ( 'foo %{a}' , { } , obj2 , obj1 ) ) . toEqual ( 'foo second' ) ;
2214+ expect ( Lib . hovertemplateString ( 'foo %{a}' , { } , locale , obj1 , obj2 ) ) . toEqual ( 'foo first' ) ;
2215+ expect ( Lib . hovertemplateString ( 'foo %{a}' , { } , locale , obj2 , obj1 ) ) . toEqual ( 'foo second' ) ;
22152216
22162217 // Nested Keys
2217- expect ( Lib . hovertemplateString ( 'foo %{foo.bar}' , { } , obj1 , obj2 ) ) . toEqual ( 'foo bar' ) ;
2218+ expect ( Lib . hovertemplateString ( 'foo %{foo.bar}' , { } , locale , obj1 , obj2 ) ) . toEqual ( 'foo bar' ) ;
22182219
22192220 // Nested keys with 0
2220- expect ( Lib . hovertemplateString ( 'y: %{y}' , { } , { y : 0 } , { y : 1 } ) ) . toEqual ( 'y: 0' ) ;
2221+ expect ( Lib . hovertemplateString ( 'y: %{y}' , { } , locale , { y : 0 } , { y : 1 } ) ) . toEqual ( 'y: 0' ) ;
22212222 } ) ;
22222223
22232224 it ( 'formats value using d3 mini-language' , function ( ) {
2224- expect ( Lib . hovertemplateString ( 'a: %{a:.0%}' , { } , { a : 0.123 } ) ) . toEqual ( 'a: 12%' ) ;
2225- expect ( Lib . hovertemplateString ( 'b: %{b:2.2f}' , { } , { b : 43 } ) ) . toEqual ( 'b: 43.00' ) ;
2225+ expect ( Lib . hovertemplateString ( 'a: %{a:.0%}' , { } , locale , { a : 0.123 } ) ) . toEqual ( 'a: 12%' ) ;
2226+ expect ( Lib . hovertemplateString ( 'a: %{a:0.2%}' , { } , locale , { a : 0.123 } ) ) . toEqual ( 'a: 12.30%' ) ;
2227+ expect ( Lib . hovertemplateString ( 'b: %{b:2.2f}' , { } , locale , { b : 43 } ) ) . toEqual ( 'b: 43.00' ) ;
22262228 } ) ;
22272229
22282230 it ( 'looks for default label if no format is provided' , function ( ) {
2229- expect ( Lib . hovertemplateString ( 'y: %{y}' , { yLabel : '0.1' } , { y : 0.123 } ) ) . toEqual ( 'y: 0.1' ) ;
2231+ expect ( Lib . hovertemplateString ( 'y: %{y}' , { yLabel : '0.1' } , locale , { y : 0.123 } ) ) . toEqual ( 'y: 0.1' ) ;
22302232 } ) ;
22312233
22322234 it ( 'warns user up to 10 times if a variable cannot be found' , function ( ) {
0 commit comments