当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript angular-mocks.module函数代码示例

本文整理汇总了TypeScript中angular-mocks.module函数的典型用法代码示例。如果您正苦于以下问题:TypeScript module函数的具体用法?TypeScript module怎么用?TypeScript module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了module函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe("Class: SparkQueryParser", function () {
    // Include dependencies
    beforeEach(mocks.module("kylo", "kylo.feedmgr", moduleName));

    // toScript
    it("should produce Spark for one table", mocks.inject(function (VisualQueryService: any) {
        const spark = new SparkQueryParser(VisualQueryService).toScript({
            "nodes": [{
                "id": 11,
                "name": "tickit.sales",
                "nodeAttributes": {
                    "attributes": [{"name": "salesid", "dataType": "int", "selected": false, "description": null}, {"name": "buyerid", "dataType": "int", "selected": false, "description": null},
                        {"name": "eventid", "dataType": "int", "selected": false, "description": null}, {"name": "dateid", "dataType": "smallint", "selected": false, "description": null},
                        {"name": "qtysold", "dataType": "string", "selected": true, "description": "number of tickets"},
                        {"name": "pricepaid", "dataType": "double", "selected": true, "description": null}, {"name": "commission", "dataType": "double", "selected": true, "description": null}],
                    "sql": "`tickit`.`sales`"
                },
                "connectors": {"bottom": {"location": "BOTTOM", "id": 4}, "left": {"location": "LEFT", "id": 1}, "right": {"location": "RIGHT", "id": 2}, "top": {"location": "TOP", "id": 3}},
                "inputConnectors": [{"name": ""}],
                "outputConnectors": [{"name": ""}],
                "width": 250
            }], "connections": []
        } as any, []);
        expect(spark).toBe("val tbl11 = sqlContext.table(\"tickit.sales\").alias(\"tbl11\")\n"
            + "var df = tbl11.select(tbl11.col(\"qtysold\").as(\"qtysold\", new org.apache.spark.sql.types.MetadataBuilder().putString(\"comment\", \"number of tickets\").build()),"
            + " tbl11.col(\"pricepaid\"), tbl11.col(\"commission\"))\n");
    }));

    it("should produce Spark for joined tables", mocks.inject(function (VisualQueryService: any) {
        const spark = new SparkQueryParser(VisualQueryService).toScript({
            "nodes": [{
                "id": 10,
                "name": "tickit.users",
                "nodeAttributes": {
                    "attributes": [{"name": "userid", "dataType": "int", "selected": false, "description": null}, {"name": "username", "dataType": "string", "selected": true, "description": null},
                        {"name": "firstname", "dataType": "string", "selected": true, "description": null}, {"name": "lastname", "dataType": "string", "selected": true, "description": null}],
                    "sql": "`tickit`.`users`"
                },
                "connectors": {"bottom": {"location": "BOTTOM", "id": 8}, "left": {"location": "LEFT", "id": 5}, "right": {"location": "RIGHT", "id": 6}, "top": {"location": "TOP", "id": 7}},
                "inputConnectors": [{"name": ""}],
                "outputConnectors": [{"name": ""}],
                "width": 250
            }, {
                "id": 11,
                "name": "tickit.sales",
                "nodeAttributes": {
                    "attributes": [{"name": "salesid", "dataType": "int", "selected": false, "description": null}, {"name": "buyerid", "dataType": "int", "selected": false, "description": null},
                        {"name": "eventid", "dataType": "int", "selected": false, "description": null}, {"name": "dateid", "dataType": "smallint", "selected": false, "description": null},
                        {"name": "qtysold", "dataType": "string", "selected": true, "description": null}, {"name": "pricepaid", "dataType": "double", "selected": true, "description": null},
                        {"name": "commission", "dataType": "double", "selected": true, "description": null}],
                    "sql": "`tickit`.`sales`"
                },
                "connectors": {"bottom": {"location": "BOTTOM", "id": 12}, "left": {"location": "LEFT", "id": 9}, "right": {"location": "RIGHT", "id": 10}, "top": {"location": "TOP", "id": 11}},
                "inputConnectors": [{"name": ""}],
                "outputConnectors": [{"name": ""}],
                "width": 250
            }, {
                "id": 12,
                "name": "tickit.event",
                "nodeAttributes": {
                    "attributes": [{"name": "eventid", "dataType": "int", "selected": false, "description": null},
                        {"name": "dateid", "dataType": "smallint", "selected": false, "description": null}, {"name": "eventname", "dataType": "string", "selected": true, "description": null}],
                    "sql": "`tickit`.`event`"
                },
                "connectors": {"bottom": {"location": "BOTTOM", "id": 16}, "left": {"location": "LEFT", "id": 13}, "right": {"location": "RIGHT", "id": 14}, "top": {"location": "TOP", "id": 15}},
                "inputConnectors": [{"name": ""}],
                "outputConnectors": [{"name": ""}],
                "width": 250
            }, {
                "id": 13,
                "name": "tickit.venue",
                "nodeAttributes": {
                    "attributes": [{"name": "venueid", "dataType": "int", "selected": false, "description": null},
                        {"name": "venuename", "dataType": "string", "selected": true, "description": null}],
                    "sql": "`tickit`.`venue`"
                },
                "connectors": {"bottom": {"location": "BOTTOM", "id": 20}, "left": {"location": "LEFT", "id": 17}, "right": {"location": "RIGHT", "id": 18}, "top": {"location": "TOP", "id": 19}},
                "inputConnectors": [{"name": ""}],
                "outputConnectors": [{"name": ""}],
                "width": 250
            }],
            "connections": [{
                "source": {"nodeID": 11, "connectorIndex": 0, "connectorId": 9},
                "dest": {"nodeID": 10, "connectorIndex": 0, "connectorID": 5},
                "joinKeys": {"sourceKey": "userid", "destKey": "buyerid"},
                "joinType": "INNER JOIN"
            }, {
                "source": {"nodeID": 12, "connectorIndex": 0, "connectorId": 13},
                "dest": {"nodeID": 11, "connectorIndex": 0, "connectorID": 9},
                "joinKeys": {"sourceKey": "eventid", "destKey": "eventid"},
                "joinType": "INNER JOIN"
            }, {
                "source": {"nodeID": 13, "connectorIndex": 0, "connectorId": 17},
                "dest": {"nodeID": 12, "connectorIndex": 0, "connectorID": 13},
                "joinKeys": {"sourceKey": "venueid", "destKey": "venueid"},
                "joinType": "INNER JOIN"
            }]
        } as any, []);
        expect(spark).toBe("val tbl10 = sqlContext.table(\"tickit.users\").alias(\"tbl10\")\n"
            + "val tbl11 = sqlContext.table(\"tickit.sales\").alias(\"tbl11\")\n"
//.........这里部分代码省略.........
开发者ID:prashanthc97,项目名称:kylo,代码行数:101,代码来源:spark-query-parser.spec.ts

示例2: describe

describe('flowchart-directive', ()=> {
	var testObject: any;
	var mockScope: any;
	var mockDragging: any;
	var mockSvgElement: any;

	//
	// Bring in the flowChart module before each test.
	//
	beforeEach(mocks.module('flowChart'));

	//
	// Helper function to create the controller for each test.
	//
	var createController = ($rootScope: any, $controller: any) =>{

 		mockScope = $rootScope.$new();
 		mockDragging = createMockDragging();
		mockSvgElement = {
			get: ()=> {
				return createMockSvgElement();
			}
		};

      	testObject = $controller('FlowChartController', {
      		$scope: mockScope,
      		dragging: mockDragging,
      		$element: mockSvgElement,
      	});
	};

	//
	// Setup the controller before each test.
	//
	beforeEach(inject(($rootScope: any, $controller: any)=> {

		createController($rootScope, $controller);
	}));

	// 
	// Create a mock DOM element.
	//
	var createMockElement: any = (attr: any, parent: any, scope: any) =>{
		return {
			attr: ()=> {
				return attr;
			},

			parent: ()=> {
				return parent;
			},		

			scope: ()=> {
				return scope || {};
			},

		};
	}

	//
	// Create a mock node data model.
	//
	var createMockNode: any = (inputConnectors: any, outputConnectors: any)=> {
		return {
			x: ()=> { return 0 },
			y: ()=> { return 0 },
			inputConnectors: inputConnectors || [],
			outputConnectors: outputConnectors || [],
			select: jasmine.createSpy('select'),
			selected: ()=> { return false; },
		};
	};

	//
	// Create a mock chart.
	//
	var createMockChart: any = (mockNodes: any, mockConnections: any)=> {
		return {
			nodes: mockNodes,
			connections: mockConnections,

			handleNodeClicked: jasmine.createSpy('handleNodeClicked'),
			handleConnectionMouseDown: jasmine.createSpy('handleConnectionMouseDown'),
			updateSelectedNodesLocation: jasmine.createSpy('updateSelectedNodesLocation'),
			deselectAll: jasmine.createSpy('deselectAll'),
			createNewConnection: jasmine.createSpy('createNewConnection'),
			applySelectionRect: jasmine.createSpy('applySelectionRect'),
		};
	};

	//
	// Create a mock dragging service.
	//
	var createMockDragging: any = ()=> {

		var mockDragging: any = {
			startDrag: (evt: any, config: any)=> {
				mockDragging.evt = evt;
				mockDragging.config = config;
			},
//.........这里部分代码省略.........
开发者ID:prashanthc97,项目名称:kylo,代码行数:101,代码来源:flowchart_directive.spec.ts

示例3: describe

describe("Class: SparkQueryEngine", function () {
    // Include dependencies
    beforeEach(mocks.module("kylo", "kylo.feedmgr", moduleName));

    // constructor
    it("should construct with a SQL statement", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                                       DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                                       VisualQueryService: any) {
        const service = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        expect(service.getScript()).toBe(
            "import org.apache.spark.sql._\n"
            + "var df = sqlContext.sql(\"SELECT * FROM invalid\")\n"
            + "df = df.limit(1000)\n"
            + "df\n");
    }));

    // canRedo
    it("should indicate redo when possible", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                                    DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                                    VisualQueryService: any) {
        const service: any = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        expect(service.canRedo()).toBe(false);

        service.redo_.push(service.newState());
        expect(service.canRedo()).toBe(true);
    }));

    // canUndo
    it("should indicate undo when possible", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                                    DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                                    VisualQueryService: any) {
        const service: any = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        expect(service.canUndo()).toBe(false);

        service.states_.push(service.newState());
        expect(service.canUndo()).toBe(true);
    }));

    // getColumnDefs
    it("should generate column type definitions", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                                         DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                                         VisualQueryService: any) {
        // Create service
        const service: any = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        service.states_[0].columns = [
            {field: "pricepaid", hiveColumnLabel: "pricepaid"},
            {field: "commission", hiveColumnLabel: "commission"},
            {field: "qtysold", hiveColumnLabel: "qtysold"}
        ];

        // Test column defs
        const defs = service.getColumnDefs();
        expect(defs).toEqual({
            "!name": "columns",
            "pricepaid": "Column",
            "commission": "Column",
            "qtysold": "Column"
        });
    }));

    // getColumnLabel
    it("should get column label for field name", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                                        DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                                        VisualQueryService: any) {
        // Create service
        const service: any = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        service.states_[0].columns = [
            {field: "col1", hiveColumnLabel: "(pricepaid - commission)"}
        ];

        // Test column labels
        expect(service.getColumnLabel("invalid")).toBe(null);
        expect(service.getColumnLabel("col1")).toBe("(pricepaid - commission)")
    }));

    // getFeedScript
    it("should get a feed script", mocks.inject(function ($http: angular.IHttpService, $mdDialog: angular.material.IDialogService, $timeout: angular.ITimeoutService,
                                                          DatasourcesService: DatasourcesServiceStatic.DatasourcesService, HiveService: any, RestUrlService: any, uiGridConstants: any,
                                                          VisualQueryService: any) {
        // Create service
        const service: any = new SparkQueryEngine($http, $mdDialog, $timeout, DatasourcesService, HiveService, RestUrlService, uiGridConstants, VisualQueryService);
        service.setQuery("SELECT * FROM invalid", []);
        service.states_[0].columns = [
            {field: "pricepaid", hiveColumnLabel: "pricepaid"},
            {field: "commission", hiveColumnLabel: "commission"},
            {field: "qtysold", hiveColumnLabel: "qtysold"}
        ];
        service.setFunctionDefs({
            "!define": {"Column": {"as": {"!spark": ".as(%s)", "!sparkType": "column"}}},
            "divide": {"!spark": "%c.divide(%c)", "!sparkType": "column"},
            "multiply": {"!spark": "%c.multiply(%c)", "!sparkType": "column"}
        });

        // Test script
        const formula = "(divide(divide(commission, pricepaid), qtysold) * 100).as(\"overhead\")";
//.........这里部分代码省略.........
开发者ID:prashanthc97,项目名称:kylo,代码行数:101,代码来源:spark-query-engine.spec.ts

示例4: describe

describe("Class: ColumnDelegate", function () {
    // Include dependencies
    beforeEach(mocks.module("kylo", "kylo.feedmgr", moduleName));

    // hideColumn
    it("should hide a column", function (done) {
        const controller = {
            pushFormula: function (formula: string, context: any) {
                expect(formula).toBe("drop(\"col1\")");
                expect(context.formula).toBe("drop(\"col1\")");
                expect(context.icon).toBe("remove_circle");
                expect(context.name).toBe("Hide col1");
                done();
            }
        } as TransformDataComponent;
        const grid = {
            api: {
                core: {
                    notifyDataChange: function () {
                    },
                    raise: {
                        columnVisibilityChanged: function () {
                        }
                    }
                }
            },
            onColumnsChange: function () {
            },
            queueGridRefresh: function () {
            },
            refresh: function () {
            }
        };

        mocks.inject(function (uiGridConstants: any) {
            const delegate = new ColumnDelegate("string", controller, null, uiGridConstants);
            delegate.hideColumn({colDef: {}, displayName: "col1", field: "col1"}, grid);
        });
    });

    // renameColumn
    it("should rename a column", function (done) {
        // Mock dialog
        let deferred: angular.IDeferred<any>;
        mocks.inject(function ($mdDialog: angular.material.IDialogService, $q: angular.IQService) {
            deferred = $q.defer();
            $mdDialog.show = function () {
                return deferred.promise;
            };
        });

        // Test rename column
        const column = {displayName: "col1", field: "col1"};
        const controller = {
            addFunction: function (formula: string, context: any) {
                expect(formula).toBe("select(username, col1.as(\"ticketprice\"), eventname)");
                expect(context.formula).toBe("select(username, col1.as(\"ticketprice\"), eventname)");
                expect(context.icon).toBe("mode_edit");
                expect(context.name).toBe("Rename col1 to ticketprice");
                done();
            }
        } as TransformDataComponent;
        const grid = {
            columns: [
                {field: "username", visible: true},
                {field: "col1", visible: true},
                {field: "eventname", visible: true}
            ]
        };

        mocks.inject(function ($rootScope: angular.IRootScopeService, $mdDialog: angular.material.IDialogService, uiGridConstants: any) {
            const delegate = new ColumnDelegate("double", controller, $mdDialog, uiGridConstants);
            delegate.renameColumn(column, grid);

            // Complete deferred
            deferred.resolve("ticketprice");
            $rootScope.$digest();
        });
    });

    // transformColumn
    it("should transform a column", function (done) {
        const column = {displayName: "col1", field: "col1"};
        const controller = {
            addFunction: function (formula: string, context: any) {
                expect(formula).toBe("select(username, upper(col1).as(\"col1\"), eventname)");
                expect(context.formula).toBe("select(username, upper(col1).as(\"col1\"), eventname)");
                expect(context.icon).toBe("arrow_upward");
                expect(context.name).toBe("Uppercase col1");
                done();
            }
        } as TransformDataComponent;
        const grid = {
            columns: [
                {field: "username", visible: true},
                {field: "col1", visible: true},
                {field: "eventname", visible: true}
            ]
        };

//.........这里部分代码省略.........
开发者ID:prashanthc97,项目名称:kylo,代码行数:101,代码来源:column-delegate.spec.ts


注:本文中的angular-mocks.module函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。