1
- import { isValid } from '../validate' ;
1
+ import { isEncodedDataUrl , isSvgDataUrl , isValid } from '../validate' ;
2
2
3
3
4
4
describe ( 'isValid' , ( ) => {
@@ -24,9 +24,11 @@ describe('isValid', () => {
24
24
} ) ;
25
25
26
26
it ( 'invalid child SCRIPT elm' , ( ) => {
27
- const el = { nodeType : 1 , nodeName : 'svg' , attributes : [ ] , childNodes : [
28
- { nodeType : 1 , nodeName : 'SCRIPT' , attributes : [ ] , childNodes : [ ] }
29
- ] } as any ;
27
+ const el = {
28
+ nodeType : 1 , nodeName : 'svg' , attributes : [ ] , childNodes : [
29
+ { nodeType : 1 , nodeName : 'SCRIPT' , attributes : [ ] , childNodes : [ ] }
30
+ ]
31
+ } as any ;
30
32
expect ( isValid ( el ) ) . toBe ( false ) ;
31
33
} ) ;
32
34
@@ -41,9 +43,11 @@ describe('isValid', () => {
41
43
} ) ;
42
44
43
45
it ( 'is valid SVG elm' , ( ) => {
44
- const el = { nodeType : 1 , nodeName : 'SVG' , attributes : [ ] , childNodes : [
45
- { nodeType : 1 , nodeName : 'line' , attributes : [ ] , childNodes : [ ] }
46
- ] } as any ;
46
+ const el = {
47
+ nodeType : 1 , nodeName : 'SVG' , attributes : [ ] , childNodes : [
48
+ { nodeType : 1 , nodeName : 'line' , attributes : [ ] , childNodes : [ ] }
49
+ ]
50
+ } as any ;
47
51
expect ( isValid ( el ) ) . toBe ( true ) ;
48
52
} ) ;
49
53
@@ -53,3 +57,17 @@ describe('isValid', () => {
53
57
} ) ;
54
58
55
59
} ) ;
60
+
61
+ it ( 'isSvgDataUrl' , ( ) => {
62
+ expect ( isSvgDataUrl ( 'data:image/svg+xml;base64,xxx' ) ) . toBe ( true ) ;
63
+ expect ( isSvgDataUrl ( 'data:image/svg+xml;utf8,<svg></svg>' ) ) . toBe ( true ) ;
64
+ expect ( isSvgDataUrl ( 'https://example.com/icon.svg' ) ) . toBe ( false ) ;
65
+ expect ( isSvgDataUrl ( 'http://example.com/icon.svg' ) ) . toBe ( false ) ;
66
+ } ) ;
67
+
68
+ it ( 'isEncodedDataUrl' , ( ) => {
69
+ expect ( isEncodedDataUrl ( 'data:image/svg+xml;base64,xxx' ) ) . toBe ( false ) ;
70
+ expect ( isEncodedDataUrl ( 'data:image/svg+xml;utf8,<svg></svg>' ) ) . toBe ( true ) ;
71
+ expect ( isEncodedDataUrl ( 'https://example.com/icon.svg' ) ) . toBe ( false ) ;
72
+ expect ( isEncodedDataUrl ( 'http://example.com/icon.svg' ) ) . toBe ( false ) ;
73
+ } ) ;
0 commit comments