File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ var Drawing = require ( '@src/components/drawing' ) ;
2+
3+ var d3 = require ( 'd3' ) ;
4+
5+
6+ describe ( 'Drawing.setClipUrl' , function ( ) {
7+ 'use strict' ;
8+
9+ beforeEach ( function ( ) {
10+ this . svg = d3 . select ( 'body' ) . append ( 'svg' ) ;
11+ this . g = this . svg . append ( 'g' ) ;
12+ } ) ;
13+
14+ it ( 'should set the clip-path attribute' , function ( ) {
15+ expect ( this . g . attr ( 'clip-path' ) ) . toBe ( null ) ;
16+
17+ Drawing . setClipUrl ( this . g , 'id1' ) ;
18+
19+ expect ( this . g . attr ( 'clip-path' ) ) . toEqual ( 'url(#id1)' ) ;
20+ } ) ;
21+
22+ it ( 'should unset the clip-path if arg is falsy' , function ( ) {
23+ this . g . attr ( 'clip-path' , 'url(#id2)' ) ;
24+
25+ Drawing . setClipUrl ( this . g , false ) ;
26+
27+ expect ( this . g . attr ( 'clip-path' ) ) . toBe ( null ) ;
28+ } ) ;
29+
30+ it ( 'should append window URL to clip-path if <base> is present' , function ( ) {
31+
32+ // append <base> with href
33+ d3 . select ( 'body' )
34+ . append ( 'base' )
35+ . attr ( 'href' , 'https://plot.ly' ) ;
36+
37+ // grab window URL
38+ var href = window . location . href ;
39+
40+ Drawing . setClipUrl ( this . g , 'id3' ) ;
41+
42+ expect ( this . g . attr ( 'clip-path' ) )
43+ . toEqual ( 'url(' + href + '#id3)' ) ;
44+ } ) ;
45+ } ) ;
You can’t perform that action at this time.
0 commit comments