本文整理汇总了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;未经允许,请勿转载。 |
请发表评论