@@ -615,6 +615,94 @@ describe('angular', function() {
615615 } ) ;
616616
617617
618+ describe ( 'jq' , function ( ) {
619+ var element ;
620+
621+ beforeEach ( function ( ) {
622+ element = document . createElement ( 'html' ) ;
623+ } ) ;
624+
625+ afterEach ( function ( ) {
626+ delete jq . name_ ;
627+ } ) ;
628+
629+ it ( 'should return undefined when jq is not set, no jQuery found (the default)' , function ( ) {
630+ expect ( jq ( ) ) . toBe ( undefined ) ;
631+ } ) ;
632+
633+ it ( 'should return empty string when jq is enabled manually via [ng-jq] with empty string' , function ( ) {
634+ element . setAttribute ( 'ng-jq' , '' ) ;
635+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
636+ if ( selector === '[ng-jq]' ) return element ;
637+ } ) ;
638+ expect ( jq ( ) ) . toBe ( '' ) ;
639+ } ) ;
640+
641+ it ( 'should return empty string when jq is enabled manually via [data-ng-jq] with empty string' , function ( ) {
642+ element . setAttribute ( 'data-ng-jq' , '' ) ;
643+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
644+ if ( selector === '[data-ng-jq]' ) return element ;
645+ } ) ;
646+ expect ( jq ( ) ) . toBe ( '' ) ;
647+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[data-ng-jq]' ) ;
648+ } ) ;
649+
650+ it ( 'should return empty string when jq is enabled manually via [x-ng-jq] with empty string' , function ( ) {
651+ element . setAttribute ( 'x-ng-jq' , '' ) ;
652+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
653+ if ( selector === '[x-ng-jq]' ) return element ;
654+ } ) ;
655+ expect ( jq ( ) ) . toBe ( '' ) ;
656+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[x-ng-jq]' ) ;
657+ } ) ;
658+
659+ it ( 'should return empty string when jq is enabled manually via [ng:jq] with empty string' , function ( ) {
660+ element . setAttribute ( 'ng:jq' , '' ) ;
661+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
662+ if ( selector === '[ng\\:jq]' ) return element ;
663+ } ) ;
664+ expect ( jq ( ) ) . toBe ( '' ) ;
665+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[ng\\:jq]' ) ;
666+ } ) ;
667+
668+ it ( 'should return "jQuery" when jq is enabled manually via [ng-jq] with value "jQuery"' , function ( ) {
669+ element . setAttribute ( 'ng-jq' , 'jQuery' ) ;
670+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
671+ if ( selector === '[ng-jq]' ) return element ;
672+ } ) ;
673+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
674+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[ng-jq]' ) ;
675+ } ) ;
676+
677+ it ( 'should return "jQuery" when jq is enabled manually via [data-ng-jq] with value "jQuery"' , function ( ) {
678+ element . setAttribute ( 'data-ng-jq' , 'jQuery' ) ;
679+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
680+ if ( selector === '[data-ng-jq]' ) return element ;
681+ } ) ;
682+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
683+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[data-ng-jq]' ) ;
684+ } ) ;
685+
686+ it ( 'should return "jQuery" when jq is enabled manually via [x-ng-jq] with value "jQuery"' , function ( ) {
687+ element . setAttribute ( 'x-ng-jq' , 'jQuery' ) ;
688+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
689+ if ( selector === '[x-ng-jq]' ) return element ;
690+ } ) ;
691+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
692+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[x-ng-jq]' ) ;
693+ } ) ;
694+
695+ it ( 'should return "jQuery" when jq is enabled manually via [ng:jq] with value "jQuery"' , function ( ) {
696+ element . setAttribute ( 'ng:jq' , 'jQuery' ) ;
697+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
698+ if ( selector === '[ng\\:jq]' ) return element ;
699+ } ) ;
700+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
701+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[ng\\:jq]' ) ;
702+ } ) ;
703+ } ) ;
704+
705+
618706 describe ( 'parseKeyValue' , function ( ) {
619707 it ( 'should parse a string into key-value pairs' , function ( ) {
620708 expect ( parseKeyValue ( '' ) ) . toEqual ( { } ) ;
0 commit comments