How to use the angular.mock function in angular

To help you get started, we’ve selected a few angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esvit / ng-table / test / specs / selectFilterDs.spec.ts View on Github external
interface ColumnScope extends IScope {
        $column: { data?: SelectData };
        $selectData?: SelectOption[];
    }

    interface TableScope extends IScope {
        $new(): ColumnScope;
    }

    let $scope: ColumnScope,
        elem: string,
        $compile: ICompileService;

    beforeAll(() => expect(ngTableBrowserModule).toBeDefined());
    beforeEach(ng1.mock.module('ngTable-browser'));

    beforeEach(inject(($rootScope: TableScope, _$compile_: ICompileService) => {
        $scope = $rootScope.$new();
        $compile = _$compile_;
        elem = '<select></select>';
    }));

    describe('array datasource', () =&gt; {

        it('should add array to current scope', () =&gt; {
            // given
            let data = [{ id: 1, title: 'A' }];
            $scope.$column = {
                data: data
            };
            // when
github i18next / ng-i18next / src / provider.spec.ts View on Github external
beforeEach(() => {

			angular.mock.module('jm.i18next', ($i18nextProvider: ng.IServiceProvider) => {
				i18next.init(i18nextOptions, (err, t) => {
					// console.log('resources loaded');
				});

				i18next.on('initialized', (options) => {
					// console.log('i18next initialized');
					i18nextOptions = options;
				});
			});

			inject((
				_$i18next_: Ii18nTranslateService,
				_$timeout_: ng.ITimeoutService,
				_$rootScope_: ng.IRootScopeService) => {
				$i18next = _$i18next_;
				$timeout = _$timeout_;
github camptocamp / ngeo / test / spec / services / csvdownload.spec.js View on Github external
describe('ngeo.download.Csv', () => {
  /** @type {import("ngeo/download/Csv.js").DownloadCsvService} */
  let ngeoCsvDownload;

  beforeEach(angular.mock.inject((_ngeoCsvDownload_) => {
    ngeoCsvDownload = _ngeoCsvDownload_;
  }));

  describe('#generateCsv', () => {
    it('deals with no data', () => {
      expect(ngeoCsvDownload.generateCsv([], [])).toBe('');
    });

    it('generates a CSV', () => {
      const columnDefs = [{name: 'col 1'}, {name: 'col 2'}, {name: 'col 3'}];
      const data = [{
        'col 1': 'some text',
        'col 2': 123,
        'col 3': true,
        'column that should be ignored': 'some text'
      }, {
github benmarch / angular-ui-tour / test / spec / config.spec.js View on Github external
describe('Tour Config', function () {
    var $compile,
        $templateCache,
        $rootScope,
        $q,
        TourConfig,
        digestAfter = function (fn, argumentArray) {
            fn.apply(null, argumentArray || []);
            $rootScope.$digest();
        };

    beforeEach(angular.mock.module('bm.uiTour'));

    beforeEach(angular.mock.inject(function (_$compile_, _$templateCache_, _$rootScope_, _$q_, _TourConfig_) {
        $compile = _$compile_;
        $templateCache = _$templateCache_;
        $rootScope = _$rootScope_;
        $q = _$q_;
        TourConfig = _TourConfig_;
    }));

    it('should initialize a new tour with default options when no options are passed', function () {
        //given
        var scope = $rootScope.$new(),
            config;

        $compile($templateCache.get('tour-with-no-config.html'))(scope);

        //when
        $rootScope.$digest();
github christianalfoni / flux-angular / tests / flux-angular-spec.js View on Github external
getItems: function() {
                return this.state.get('items')
              },
            },
          }
        })
        .store('MyStoreC', function() {
          return {
            initialize: function() {
              this.state = this.immutable({ items: [] }, { asynchronous: true })
            },
            exports: {},
          }
        })

      angular.mock.module('test')
    }
github mattlewis92 / angular-bootstrap-calendar / test / unit / directives / mwlResizable.spec.js View on Github external
'resize-edges="{top: true, bottom: true}" ' +
      'on-resize-start="onResizeStart()" ' +
      'on-resize-end="onResizeEnd(x, y)" ' +
      'on-resize="onResize(x, y)" ' +
      '&gt;';

  function prepareScope(vm) {
    //These variables MUST be set as a minimum for the calendar to work
    vm.resizable = true;
    vm.dropData = 'myData';
    vm.onResizeStart = sinon.spy();
    vm.onResize = sinon.spy();
    vm.onResizeEnd = sinon.spy();
  }

  beforeEach(angular.mock.module('mwl.calendar'));

  beforeEach(angular.mock.module(function($provide) {
    interact = sinon.stub();
    interact.createSnapGrid = sinon.spy();
    $provide.constant('interact', interact);
  }));

  beforeEach(angular.mock.inject(function(_$compile_, _$rootScope_, _$timeout_) {
    $compile = _$compile_;
    $rootScope = _$rootScope_;
    $timeout = _$timeout_;
    scope = $rootScope.$new();
    prepareScope(scope);

    interactInstance = {
      resizable: sinon.spy(),
github Enalean / tuleap / plugins / tracker / www / scripts / angular-artifact-modal / src / tuleap-artifact-modal-fields / file-field / file-upload-service.spec.js View on Github external
beforeEach(() => {
        angular.mock.module(file_field_module);

        angular.mock.inject(function(
            _$q_,
            _TuleapArtifactModalFileUploadService_
        ) {
            $q                                   = _$q_;
            TuleapArtifactModalFileUploadService = _TuleapArtifactModalFileUploadService_;
        });

        installPromiseMatchers();
    });
github Talend / data-prep / dataprep-webapp / src / app / components / widgets-containers / inventory-list / inventory-list-container.spec.js View on Github external
describe('Inventory list container', () =&gt; {
	let scope;
	let createElement;
	let element;
	const body = angular.element('body');

	beforeEach(angular.mock.module('@talend/react-components.containers'));

	beforeEach(inject(($rootScope, $compile, SettingsService) =&gt; {
		scope = $rootScope.$new(true);

		createElement = () =&gt; {
			element = angular.element(`
github Enalean / tuleap / plugins / agiledashboard / www / js / kanban / src / app / reports-modal / reports-modal-controller.spec.js View on Github external
beforeEach(function() {
        angular.mock.module(kanban_module);

        var $controller,
            $rootScope;

        angular.mock.inject(function(
            _$controller_,
            _$q_,
            _$rootScope_,
            _SharedPropertiesService_,
            _DiagramRestService_
        ) {
            $controller             = _$controller_;
            $q                      = _$q_;
            $rootScope              = _$rootScope_;
            SharedPropertiesService = _SharedPropertiesService_;
            DiagramRestService      = _DiagramRestService_;
        });

        $scope = $rootScope.$new();

        kanban_id    = 2;
github Enalean / tuleap / scripts / angular / src / app / execution / execution-link-issue-controller.spec.js View on Github external
beforeEach(() => {
        angular.mock.module(execution_module);

        let $controller, $rootScope;

        angular.mock.inject(function(
            _$controller_,
            _$q_,
            _$rootScope_,
            _ExecutionRestService_,
            _SharedPropertiesService_
        ) {
            $controller = _$controller_;
            $q = _$q_;
            $rootScope = _$rootScope_;
            ExecutionRestService = _ExecutionRestService_;
            SharedPropertiesService = _SharedPropertiesService_;
        });