Repository: angular/angular.js
File: test/ng/compileSpec.js (JavaScript)

Code before:
      expect(componentScope.$$isolateBindings.attrAlias.attrName).toBe('attr');
      expect(componentScope.$$isolateBindings.$attrAlias.attrName).toBe('$attr$');
      expect(componentScope.$$isolateBindings.ref.mode).toBe('=');
      expect(componentScope.$$isolateBindings.ref.attrName).toBe('ref');
      expect(componentScope.$$isolateBindings.refAlias.attrName).toBe('ref');
      expect(componentScope.$$isolateBindings.$refAlias.attrName).toBe('$ref$');
      expect(componentScope.$$isolateBindings.reference.mode).toBe('=');
      expect(componentScope.$$isolateBindings.reference.attrName).toBe('reference');
      expect(componentScope.$$isolateBindings.owRef.mode).toBe('<');
      expect(componentScope.$$isolateBindings.owRef.attrName).toBe('owRef');
      expect(componentScope.$$isolateBindings.owRefAlias.attrName).toBe('owRef');
      expect(componentScope.$$isolateBindings.$owRefAlias.attrName).toBe('$owRef$');
      expect(componentScope.$$isolateBindings.expr.mode).toBe('&');
      expect(componentScope.$$isolateBindings.expr.attrName).toBe('expr');
      expect(componentScope.$$isolateBindings.exprAlias.attrName).toBe('expr');
      expect(componentScope.$$isolateBindings.$exprAlias.attrName).toBe('$expr$');

      var firstComponentScope = componentScope,
          first$$isolateBindings = componentScope.$$isolateBindings;

      dealoc(element);
      compile('<div><span my-component>');
      expect(componentScope).not.toBe(firstComponentScope);
      expect(componentScope.$$isolateBindings).toBe(first$$isolateBindings);
    }));


    it('should expose isolate scope variables on controller with controllerAs when bindToController is true (template)', function() {
      var controllerCalled = false;
      module(function($compileProvider) {
        $compileProvider.directive('fooDir', valueFn({
          template: '<p>isolate</p>',
          scope: {
            'data': '=dirData',
            'oneway': '<dirData',
            'str': '@dirStr',
            'fn': '&dirFn'
          },
          controller: function($scope) {
            this.$onInit = function() {
              expect(this.data).toEqualData({
                'foo': 'bar',
                'baz': 'biz'
              });
              expect(this.oneway).toEqualData({
                'foo': 'bar',
                'baz': 'biz'
              });
              expect(this.str).toBe('Hello, world!');
              expect(this.fn()).toBe('called!');
            };

Review comment (suggestion):
Missing a test to verify the `$watchCollection` part. (AFAICT, these tests would have passed even if `*` was ignored.)

Code after:
          name: 'Gabriel',
          value: 18
        };
        $rootScope.tony = {
          name: 'Tony',
          value: 91
        };
        $rootScope.$apply();

        compile('<div><span my-component ow-colref="[gab, tony]" $ow-colref$="[gab, tony]">');

        expect(componentScope.owColref).toEqual([$rootScope.gab, $rootScope.tony]);
        expect(componentScope.owColrefAlias).toEqual([$rootScope.gab, $rootScope.tony]);
        expect(componentScope.$owColrefAlias).toEqual([$rootScope.gab, $rootScope.tony]);

        $rootScope.tony = {
          name: 'Bob',
          value: 42
        };
        $rootScope.$apply();

        expect(componentScope.owColref).toEqual([$rootScope.gab, $rootScope.tony]);
        expect(componentScope.owColrefAlias).toEqual([$rootScope.gab, $rootScope.tony]);
        expect(componentScope.$owColrefAlias).toEqual([$rootScope.gab, $rootScope.tony]);
      }));
    });

    describe('executable expression', function() {
      it('should allow expression execution with locals', inject(function() {
        compile('<div><span my-component expr="count = count + offset" $expr$="count = count + offset">');
        $rootScope.count = 2;

        expect(typeof componentScope.expr).toBe('function');
        expect(typeof componentScope.exprAlias).toBe('function');
        expect(typeof componentScope.$exprAlias).toBe('function');

        expect(componentScope.expr({offset: 1})).toEqual(3);
        expect($rootScope.count).toEqual(3);

        expect(componentScope.exprAlias({offset: 10})).toEqual(13);
        expect(componentScope.$exprAlias({offset: 10})).toEqual(23);
        expect($rootScope.count).toEqual(23);
      }));
    });

    it('should throw on unknown definition', inject(function() {
      expect(function() {
        compile('<div><span bad-declaration>');
      }).toThrowMinErr('$compile', 'iscp', 'Invalid isolate scope definition for directive \'badDeclaration\'. Definition: {... attr: \'xxx\' ...}');
    }));