@@ -39,8 +39,8 @@ define(function (require, exports, module) {
3939 "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" +
4040 " width=\"200\" height=\"200\" preserveAspectRatio=\"xMinYMin meet\">\n" +
4141 " <title>Brackets SVG Code Hints</title>\n" +
42- " <rect width=\"200\" height=\"200\" baseline-shift=\"baseline\" alignment-baseline=\"alphabetic\" stroke-width=\"1\"></rect>\n" +
43- " <rect width='160' height='160' x='20' y='20' baseline-shift='super' alignment-baseline='baseline' />\n" +
42+ " <rect width=\"200\" height=\"200\" baseline-shift=\"baseline\" alignment-baseline=\"alphabetic\" stroke-width=\"1\" color=\"\" ></rect>\n" +
43+ " <rect width='160' height='160' x='20' y='20' baseline-shift='super' alignment-baseline='baseline' color='rent' fill='transparent' />\n" +
4444 " <g>\n" +
4545 " \n" +
4646 " </g>\n" +
@@ -205,7 +205,7 @@ define(function (require, exports, module) {
205205 expectNoHints ( SVGCodeHints . hintProvider ) ;
206206
207207 // Between <rect></rect>
208- testEditor . setCursorPos ( { line : 4 , ch : 110 } ) ;
208+ testEditor . setCursorPos ( { line : 4 , ch : 119 } ) ;
209209 expectNoHints ( SVGCodeHints . hintProvider ) ;
210210
211211 // After <title>+space in <title> Brackets
@@ -216,21 +216,21 @@ define(function (require, exports, module) {
216216
217217 it ( "should not hint after the closed tag" , function ( ) {
218218 // After </rect>
219- testEditor . setCursorPos ( { line : 4 , ch : 117 } ) ;
219+ testEditor . setCursorPos ( { line : 4 , ch : 126 } ) ;
220220 expectNoHints ( SVGCodeHints . hintProvider ) ;
221221
222222 // After space at </rect>+space
223- testDocument . replaceRange ( " " , { line : 4 , ch : 117 } ) ;
224- testEditor . setCursorPos ( { line : 4 , ch : 118 } ) ;
223+ testDocument . replaceRange ( " " , { line : 4 , ch : 126 } ) ;
224+ testEditor . setCursorPos ( { line : 4 , ch : 127 } ) ;
225225 expectNoHints ( SVGCodeHints . hintProvider ) ;
226226
227227 // After />
228- testEditor . setCursorPos ( { line : 5 , ch : 104 } ) ;
228+ testEditor . setCursorPos ( { line : 5 , ch : 136 } ) ;
229229 expectNoHints ( SVGCodeHints . hintProvider ) ;
230230
231231 // After space in />+space
232- testDocument . replaceRange ( " " , { line : 5 , ch : 104 } ) ;
233- testEditor . setCursorPos ( { line : 5 , ch : 105 } ) ;
232+ testDocument . replaceRange ( " " , { line : 5 , ch : 136 } ) ;
233+ testEditor . setCursorPos ( { line : 5 , ch : 137 } ) ;
234234 expectNoHints ( SVGCodeHints . hintProvider ) ;
235235
236236 // After </g>
@@ -453,6 +453,38 @@ define(function (require, exports, module) {
453453 } ) ;
454454 } ) ;
455455
456+ describe ( "Color names and swatches" , function ( ) {
457+ it ( "should show color swatches" , function ( ) {
458+ // After color="
459+ testEditor . setCursorPos ( { line : 4 , ch : 117 } ) ;
460+ var hints = expectHints ( SVGCodeHints . hintProvider ) ;
461+ verifyHints ( hints , "aliceblue" ) ; // first hint should be aliceblue
462+ expect ( hints [ 0 ] . find ( ".color-swatch" ) . length ) . toBe ( 1 ) ;
463+ expect ( hints [ 0 ] . find ( ".color-swatch" ) . css ( "backgroundColor" ) ) . toBe ( "rgb(240, 248, 255)" ) ;
464+ } ) ;
465+
466+ it ( "should always include transparent and currentColor and they should not have a swatch, but class no-swatch-margin" , function ( ) {
467+ // After color='rent
468+ testEditor . setCursorPos ( { line : 5 , ch : 113 } ) ;
469+ var hints = expectHints ( SVGCodeHints . hintProvider ) ;
470+ verifyHints ( hints , "currentColor" ) ; // first hint should be currentColor
471+ expect ( hints [ 0 ] . find ( ".color-swatch" ) . length ) . toBe ( 0 ) ; // no swatch for currentColor
472+ expect ( hints [ 2 ] . find ( ".color-swatch" ) . length ) . toBe ( 0 ) ; // no swatch for transparent
473+ expect ( hints [ 0 ] . hasClass ( "no-swatch-margin" ) ) . toBeTruthy ( ) ; // no-swatch-margin applied to currentColor
474+ expect ( hints [ 2 ] . hasClass ( "no-swatch-margin" ) ) . toBeTruthy ( ) ; // no-swatch-margin applied to transparent
475+ } ) ;
476+
477+ it ( "should remove class no-swatch-margin from transparent if it's the only one in the list" , function ( ) {
478+ // After fill='transparent
479+ testEditor . setCursorPos ( { line : 5 , ch : 132 } ) ;
480+ var hints = expectHints ( SVGCodeHints . hintProvider ) ;
481+ verifyHints ( hints , "transparent" ) ;
482+ expect ( hints . length ) . toBe ( 1 ) ; // transparent should be the only hint
483+ expect ( hints [ 0 ] . find ( ".color-swatch" ) . length ) . toBe ( 0 ) ; // no swatch for transparent
484+ expect ( hints [ 0 ] . hasClass ( "no-swatch-margin" ) ) . toBeFalsy ( ) ; // no-swatch-margin not applied to transparent
485+ } ) ;
486+ } ) ;
487+
456488 describe ( "Tag Insertion" , function ( ) {
457489 it ( "should insert if query is empty" , function ( ) {
458490 // After < inside <g>
0 commit comments