Repository: angular/angular.js
File: test/AngularSpec.js (JavaScript)

Code before:
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: false });
    });


    it('should return true for all rules when CSP is enabled manually via empty `ng-csp` attribute', function() {
      var spy = mockCspElement('ng-csp');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
      expect(spy).toHaveBeenCalledWith('[ng-csp]');
    });


    it('should return true when CSP is enabled manually via [data-ng-csp]', function() {
      var spy = mockCspElement('data-ng-csp');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
      expect(document.querySelector).toHaveBeenCalledWith('[data-ng-csp]');
    });


    it('should return true for noUnsafeEval if it is specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-unsafe-eval');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: false });
    });


    it('should return true for noInlineStyle if it is specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-inline-style');
      expect(csp()).toEqual({ noUnsafeEval: false, noInlineStyle: true });
    });


    it('should return true for all styles if they are all specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-inline-style;no-unsafe-eval');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
    });
  });


  describe('jq', function() {
    var element;

    beforeEach(function() {
      element = document.createElement('html');
    });

    afterEach(function() {
      delete jq.name_;
    });

    it('should return undefined when jq is not set, no jQuery found (the default)', function() {
      expect(jq()).toBe(undefined);
    });

Review comment (suggestion):
It might be also nice to test that no check is performed (i.e. spying on `window.Function` to verify it hasn't been called or something).


Code after:
      expect(window.Function).toHaveBeenCalledWith('');
    });


    it('should return true for all rules when CSP is enabled manually via empty `ng-csp` attribute', function() {
      var spy = mockCspElement('ng-csp');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
      expect(spy).toHaveBeenCalledWith('[ng-csp]');
      expect(window.Function).not.toHaveBeenCalled();
    });


    it('should return true when CSP is enabled manually via [data-ng-csp]', function() {
      var spy = mockCspElement('data-ng-csp');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
      expect(spy).toHaveBeenCalledWith('[data-ng-csp]');
      expect(window.Function).not.toHaveBeenCalled();
    });


    it('should return true for noUnsafeEval if it is specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-unsafe-eval');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: false });
      expect(spy).toHaveBeenCalledWith('[ng-csp]');
      expect(window.Function).not.toHaveBeenCalled();
    });


    it('should return true for noInlineStyle if it is specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-inline-style');
      expect(csp()).toEqual({ noUnsafeEval: false, noInlineStyle: true });
      expect(spy).toHaveBeenCalledWith('[ng-csp]');
      expect(window.Function).not.toHaveBeenCalled();
    });


    it('should return true for all styles if they are all specified in the `ng-csp` attribute value', function() {
      var spy = mockCspElement('ng-csp', 'no-inline-style;no-unsafe-eval');
      expect(csp()).toEqual({ noUnsafeEval: true, noInlineStyle: true });
      expect(spy).toHaveBeenCalledWith('[ng-csp]');
      expect(window.Function).not.toHaveBeenCalled();
    });
  });


  describe('jq', function() {
    var element;

    beforeEach(function() {
      element = document.createElement('html');
    });