@@ -615,6 +615,58 @@ describe('angular', function() {
615
615
} ) ;
616
616
617
617
618
+ describe ( 'jq' , function ( ) {
619
+ var element , fakeQuery ;
620
+
621
+ beforeEach ( function ( ) {
622
+ element = document . createElement ( 'html' ) ;
623
+ } ) ;
624
+
625
+ afterEach ( function ( ) {
626
+ jq . name_ = undefined ;
627
+ delete jq . name_ ;
628
+ } ) ;
629
+
630
+ it ( 'should return undefined when jq is not set, no jquery found (the default)' , function ( ) {
631
+ expect ( jq ( ) ) . toBe ( undefined ) ;
632
+ } ) ;
633
+
634
+ it ( 'should return empty string when jq is enabled manually via [ng-jq] with empty string' , function ( ) {
635
+ element . setAttribute ( 'ng-jq' , '' ) ;
636
+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
637
+ if ( selector == '[ng-jq]' ) return element ;
638
+ } ) ;
639
+ expect ( jq ( ) ) . toBe ( '' ) ;
640
+ } ) ;
641
+
642
+ it ( 'should return empty string when jq is enabled manually via [data-ng-jq] with empty string' , function ( ) {
643
+ element . setAttribute ( 'data-ng-jq' , '' ) ;
644
+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
645
+ if ( selector == '[data-ng-jq]' ) return element ;
646
+ } ) ;
647
+ expect ( jq ( ) ) . toBe ( '' ) ;
648
+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[data-ng-jq]' ) ;
649
+ } ) ;
650
+
651
+ it ( 'should return "jquery" when jq is enabled manually via [ng-jq] with value "jquery"' , function ( ) {
652
+ element . setAttribute ( 'ng-jq' , 'jQuery' ) ;
653
+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
654
+ if ( selector == '[ng-jq]' ) return element ;
655
+ } ) ;
656
+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
657
+ } ) ;
658
+
659
+ it ( 'should return "jquery" when jq is enabled manually via [data-ng-jq] with value "jquery"' , function ( ) {
660
+ element . setAttribute ( 'data-ng-jq' , 'jQuery' ) ;
661
+ spyOn ( document , 'querySelector' ) . andCallFake ( function ( selector ) {
662
+ if ( selector == '[data-ng-jq]' ) return element ;
663
+ } ) ;
664
+ expect ( jq ( ) ) . toBe ( 'jQuery' ) ;
665
+ expect ( document . querySelector ) . toHaveBeenCalledWith ( '[data-ng-jq]' ) ;
666
+ } ) ;
667
+ } ) ;
668
+
669
+
618
670
describe ( 'parseKeyValue' , function ( ) {
619
671
it ( 'should parse a string into key-value pairs' , function ( ) {
620
672
expect ( parseKeyValue ( '' ) ) . toEqual ( { } ) ;
0 commit comments