@@ -42,6 +42,97 @@ describe('processBackgroundImage', () => {
4242 ] ) ;
4343 } ) ;
4444
45+ it ( 'should process a conic gradient string' , ( ) => {
46+ const result = processBackgroundImage (
47+ 'conic-gradient(from 45deg at 25% 75%, red 0deg, blue .5turn, red 100%)' ,
48+ ) ;
49+
50+ expect ( result ) . toEqual ( [
51+ {
52+ type : 'conic-gradient' ,
53+ from : 45 ,
54+ position : { left : '25%' , top : '75%' } ,
55+ colorStops : [
56+ { color : processColor ( 'red' ) , position : '0%' } ,
57+ { color : processColor ( 'blue' ) , position : '50%' } ,
58+ { color : processColor ( 'red' ) , position : '100%' } ,
59+ ] ,
60+ } ,
61+ ] ) ;
62+ } ) ;
63+
64+ it ( 'should process a conic gradient with four-value position' , ( ) => {
65+ expect (
66+ processBackgroundImage (
67+ 'conic-gradient(at top 20px left 10px, red, blue)' ,
68+ ) ,
69+ ) . toEqual ( [
70+ {
71+ type : 'conic-gradient' ,
72+ from : 0 ,
73+ position : { top : 20 , left : 10 } ,
74+ colorStops : [
75+ { color : processColor ( 'red' ) , position : null } ,
76+ { color : processColor ( 'blue' ) , position : null } ,
77+ ] ,
78+ } ,
79+ ] ) ;
80+ } ) ;
81+
82+ it ( 'should process conic gradient object syntax' , ( ) => {
83+ const input : ReadonlyArray < BackgroundImageValue > = [
84+ {
85+ type : 'conic-gradient' ,
86+ from : '0.25turn' ,
87+ position : { top : '50%' , left : '50%' } ,
88+ colorStops : [
89+ { color : 'red' , positions : [ '0deg' , '90deg' ] } ,
90+ { color : 'blue' , positions : [ '90deg' , '360deg' ] } ,
91+ ] ,
92+ } ,
93+ ];
94+
95+ expect(processBackgroundImage(input)).toEqual([
96+ {
97+ type : 'conic-gradient' ,
98+ from : 90 ,
99+ position : { top : '50%' , left : '50%' } ,
100+ colorStops : [
101+ { color : processColor ( 'red' ) , position : '0%' } ,
102+ { color : processColor ( 'red' ) , position : '25%' } ,
103+ { color : processColor ( 'blue' ) , position : '25%' } ,
104+ { color : processColor ( 'blue' ) , position : '100%' } ,
105+ ] ,
106+ } ,
107+ ]);
108+ } ) ;
109+
110+ it ( 'should reject invalid conic gradient object stops ', ( ) => {
111+ expect (
112+ processBackgroundImage ( [
113+ {
114+ type : 'conic-gradient' ,
115+ colorStops : [ { color : 'red' } ] ,
116+ } ,
117+ ] ) ,
118+ ) . toEqual ( [ ] ) ;
119+
120+ const numericStop = [
121+ {
122+ type : 'conic-gradient' ,
123+ colorStops : [ { color : 'red' , positions : [ 50 ] } , { color : 'blue' } ] ,
124+ } ,
125+ ] ;
126+ // $FlowFixMe[incompatible-type] - verifies runtime validation.
127+ expect ( processBackgroundImage ( numericStop ) ) . toEqual ( [ ] ) ;
128+ } );
129+
130+ it('should reject conic gradient length color stops', () => {
131+ expect ( processBackgroundImage ( 'conic-gradient(red 10px, blue)' ) ) . toEqual (
132+ [ ] ,
133+ ) ;
134+ } );
135+
45136 it('should process a diagonal linear gradient', () => {
46137 const input = 'linear-gradient(to bottom right, red, blue)' ;
47138 const result = processBackgroundImage ( input ) ;
0 commit comments