當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular-mocks.inject函數代碼示例

本文整理匯總了TypeScript中angular-mocks.inject函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript inject函數的具體用法?TypeScript inject怎麽用?TypeScript inject使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了inject函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

 describe("get fields", function () {
     it("from applied transformation", 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", []);
         service.states_[0].columns = [
             {dataType: "string", hiveColumnLabel: "username", comment: null},
             {dataType: "decimal(8,2)", hiveColumnLabel: "(pricepaid - commission) / qtysold", comment: "avg tkt price"}
         ];
         expect(service.getFields()).toEqual([
             {name: "username", description: null, dataType: "string", primaryKey: false, nullable: false, sampleValues: [], derivedDataType: "string"},
             {
                 name: "(pricepaid - commission) / qtysold", description: "avg tkt price", dataType: "decimal", primaryKey: false, nullable: false, sampleValues: [], precisionScale: "8,2",
                 derivedDataType: "decimal"
             }
         ]);
     }));
     it("from null columns", 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.getFields()).toBe(null);
     }));
 });
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:26,代碼來源:spark-query-engine.spec.ts

示例2: it

    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}
            ]
        };

        mocks.inject(function (uiGridConstants: any) {
            const delegate = new ColumnDelegate("string", controller, null, uiGridConstants);
            delegate.transformColumn({description: "Uppercase", icon: "arrow_upward", name: "Upper Case", operation: "upper"},
                column, grid);
        });
    });
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:25,代碼來源:column-delegate.spec.ts

示例3: 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


注:本文中的angular-mocks.inject函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。