@@ -103,66 +103,6 @@ define(function (require, exports, module) {
103103 }
104104
105105
106- describe ( "Emmet hint provider" , function ( ) {
107-
108- it ( "should display boiler plate code on ! press" , function ( ) {
109-
110- let emmetBoilerPlate = "<!DOCTYPE html>\n" +
111- "<html lang=\"en\">\n" +
112- "<head>\n" +
113- " <meta charset=\"UTF-8\">\n" +
114- " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
115- " <title>Document</title>\n" +
116- "</head>\n" +
117- "<body>\n" +
118- "\n" +
119- "</body>\n" +
120- "</html>\n" ;
121-
122- testDocument . setText ( "!" ) ;
123- testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
124- let emmetHintList = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
125- verifyTagHints ( emmetHintList , emmetBoilerPlate ) ;
126- } ) ;
127-
128- it ( "should display doctype html initial line on !!! press" , function ( ) {
129-
130- let emmetBoilerPlate = "<!DOCTYPE html>" ;
131-
132- testDocument . setText ( "!!!" ) ;
133- testEditor . setCursorPos ( { line : 0 , ch : 3 } ) ;
134- let emmetHintList = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
135- verifyTagHints ( emmetHintList , emmetBoilerPlate ) ;
136- } ) ;
137-
138- it ( "should not display emmet hints on < key press" , function ( ) {
139- testDocument . setText ( "<" ) ;
140- testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
141- expectNoHints ( HTMLCodeHints . emmetHintProvider ) ;
142- } ) ;
143-
144- it ( "should add class name id name if abbr contains . and #" , function ( ) {
145-
146- console . log ( '--------------------------' ) ;
147- console . log ( "reached here" ) ;
148- console . log ( '--------------------------' ) ;
149-
150- testDocument . setText ( "div.hello#world" ) ;
151- testEditor . setCursorPos ( { line : 0 , ch : 15 } ) ;
152- let emmetHintList = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
153- verifyTagHints ( emmetHintList , "<div class=\"hello\" id=\"world\"></div>" ) ;
154- } ) ;
155-
156- it ( ". should expand to a div with empty class name and set cursor in between quotes" , function ( ) {
157- testDocument . setText ( "." ) ;
158- testEditor . setCursorPos ( { line : 0 , ch : 0 } ) ;
159- var hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
160- HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
161- expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 0 , ch : 12 } ) ) ;
162- } ) ;
163- } ) ;
164-
165-
166106 describe ( "Tag hint provider" , function ( ) {
167107
168108 it ( "should not hint within <style> block" , function ( ) { // (bug #1277)
@@ -753,5 +693,127 @@ define(function (require, exports, module) {
753693 } ) ;
754694
755695
696+ describe ( "Emmet hint provider" , function ( ) {
697+
698+ it ( "should display emmet hint and expand to boilerplate code on ! press" , function ( ) {
699+
700+ let emmetBoilerPlate = [
701+ "<!DOCTYPE html>" ,
702+ "<html lang=\"en\">" ,
703+ "<head>" ,
704+ " <meta charset=\"UTF-8\">" ,
705+ " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" ,
706+ " <title>Document</title>" ,
707+ "</head>" ,
708+ "<body>" ,
709+ " " ,
710+ "</body>" ,
711+ "</html>"
712+ ] ;
713+
714+ testDocument . setText ( "!" ) ;
715+ testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
716+ const hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
717+
718+ // get the hintText from the code hint
719+ const hintText = hints [ 0 ] [ 0 ] . textContent ;
720+ expect ( hintText ) . toBe ( "!Emmet" ) ; // this should be same as the setText plus the Emmet
721+
722+ // also test after inserting the hint
723+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
724+
725+ for ( let i = 0 ; i <= 10 ; i ++ ) {
726+ expect ( testDocument . getLine ( i ) ) . toBe ( emmetBoilerPlate [ i ] ) ;
727+ }
728+
729+ // make sure the cursor is between the body tag
730+ expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 8 , ch : 1 } ) ) ;
731+ } ) ;
732+
733+
734+ it ( "should display emmet hint and expand to doctype html initial line on !!! press" , function ( ) {
735+
736+ let emmetBoilerPlate = "<!DOCTYPE html>" ;
737+
738+ testDocument . setText ( "!!!" ) ;
739+ testEditor . setCursorPos ( { line : 0 , ch : 3 } ) ;
740+ const hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
741+
742+ const hintText = hints [ 0 ] [ 0 ] . textContent ;
743+ expect ( hintText ) . toBe ( "!!!Emmet" ) ;
744+
745+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
746+ expect ( testDocument . getLine ( 0 ) ) . toBe ( emmetBoilerPlate ) ;
747+
748+ expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 0 , ch : 15 } ) ) ;
749+ } ) ;
750+
751+ it ( "should not display hints when two or more than three exclamation marks are present" , function ( ) {
752+ testDocument . setText ( "!!" ) ;
753+ testEditor . setCursorPos ( { line : 0 , ch : 2 } ) ;
754+ expectNoHints ( HTMLCodeHints . emmetHintProvider ) ;
755+
756+ testDocument . setText ( "!!!!" ) ;
757+ testEditor . setCursorPos ( { line : 0 , ch : 4 } ) ;
758+ expectNoHints ( HTMLCodeHints . emmetHintProvider ) ;
759+ } ) ;
760+
761+ it ( "should not display emmet hints on < key press" , function ( ) {
762+ testDocument . setText ( "<" ) ;
763+ testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
764+ expectNoHints ( HTMLCodeHints . emmetHintProvider ) ;
765+ } ) ;
766+
767+ it ( "should add class name id name if abbr contains . and #" , function ( ) {
768+ testDocument . setText ( "div.hello#world" ) ;
769+ testEditor . setCursorPos ( { line : 0 , ch : 15 } ) ;
770+
771+ const hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
772+
773+ const hintText = hints [ 0 ] [ 0 ] . textContent ;
774+ expect ( hintText ) . toBe ( "div.hello#worldEmmet" ) ;
775+
776+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
777+ expect ( testDocument . getLine ( 0 ) ) . toBe ( "<div class=\"hello\" id=\"world\"></div>" ) ;
778+
779+ expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 0 , ch : 30 } ) ) ;
780+ } ) ;
781+
782+ it ( "./# should expand to a div with empty class/id name and set cursor in between quotes" , function ( ) {
783+ testDocument . setText ( "." ) ;
784+ testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
785+ let hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
786+
787+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
788+ expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 0 , ch : 12 } ) ) ;
789+
790+ testDocument . setText ( "#" ) ;
791+ testEditor . setCursorPos ( { line : 0 , ch : 1 } ) ;
792+ hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
793+
794+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
795+ expect ( fixPos ( testEditor . getCursorPos ( ) ) ) . toEql ( fixPos ( { line : 0 , ch : 9 } ) ) ;
796+ } ) ;
797+
798+ it ( "should expand emmet snippet with * and {}" , function ( ) {
799+ const emmetSnippetResult = "<ul>\n" +
800+ " <li>hello world</li>\n" +
801+ " <li>hello world</li>\n" +
802+ " <li>hello world</li>\n" +
803+ " <li>hello world</li>\n" +
804+ "</ul>" ;
805+ testDocument . setText ( "ul>li*4{hello world}" ) ;
806+ testEditor . setCursorPos ( { line : 0 , ch : 19 } ) ;
807+ const hints = expectHints ( HTMLCodeHints . emmetHintProvider ) ;
808+
809+ const hintText = hints [ 0 ] [ 0 ] . textContent ;
810+ expect ( hintText ) . toBe ( "ul>li*4{hello world}Emmet" ) ;
811+
812+ HTMLCodeHints . emmetHintProvider . insertHint ( hints [ 0 ] ) ;
813+ expect ( testDocument . getText ( ) ) . toBe ( emmetSnippetResult ) ;
814+ } ) ;
815+ } ) ;
816+
817+
756818 } ) ; // describe("HTML Code Hinting"
757819} ) ;
0 commit comments