ng-typeview
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -36,2 +36,26 @@ import * as ts from "typescript"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeArrowFunction: (input: ts.Node | undefined) => Maybe<ts.ArrowFunction>; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeFunctionExpression: (input: ts.Node | undefined) => Maybe<ts.FunctionExpression>; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeBlock: (input: ts.Node | undefined) => Maybe<ts.Block>; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeReturnStatement: (input: ts.Node | undefined) => Maybe<ts.ReturnStatement>; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeAsExpression: (input: ts.Node | undefined) => Maybe<ts.AsExpression>; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const maybeArrayLiteralExpression: (input: ts.Node | undefined) => Maybe<ts.ArrayLiteralExpression>; | ||
/** | ||
* Returned by [[ControllerViewConnector.getControllerView]] | ||
@@ -53,2 +77,20 @@ * Describes a connection between a controller (TS file) | ||
/** | ||
* Returned by [[ModelViewConnector.getControllerView]] | ||
* Describes a connection between a controller or directive (TS file | ||
* containing a scope), and a view (HTML file). | ||
*/ | ||
export interface ModelViewInfo { | ||
/** | ||
* Path to a file containing an angular controller scope | ||
* (can be a controller or a directive, the important thing | ||
* is that it contains the scope to use for the view) | ||
*/ | ||
readonly modelPath: string; | ||
/** | ||
* Path to an angular view (file name within the project, | ||
* NOT absolute path on disk). | ||
*/ | ||
readonly viewPath: string; | ||
} | ||
/** | ||
* @hidden | ||
@@ -61,2 +103,3 @@ */ | ||
readonly controllerViewInfos: ControllerViewInfo[]; | ||
readonly modelViewInfos: ModelViewInfo[]; | ||
} | ||
@@ -87,2 +130,25 @@ /** | ||
/** | ||
* You can register such a connector using [[ProjectSettings.modelViewConnectors]]. | ||
* Will be called when parsing typescript files, allows you to tell ng-typeview | ||
* about connections between scopes and views made in your code (whether the scope | ||
* is defined in a controller or a directive for instance). | ||
*/ | ||
export interface ModelViewConnector { | ||
/** | ||
* Which AST node you want to be listening for | ||
*/ | ||
interceptAstNode: ts.SyntaxKind; | ||
/** | ||
* When your view connector is registered and we parse a TS file and | ||
* ecounter an AST node with the type you specified through [[interceptAstNode]], | ||
* this function will be called. | ||
* @param filename the typescript file name | ||
* @param node the AST node which matched your specification | ||
* @param projectPath the path of the project on disk | ||
* @returns the controller-view connections that you detected for this node, | ||
* if any (the empty array if you didn't detect any). | ||
*/ | ||
getModelView: (filename: string, node: ts.Node, projectPath: string) => ModelViewInfo[]; | ||
} | ||
/** | ||
* Default set of [[ControllerViewConnector]] which can recognize connections between | ||
@@ -95,5 +161,12 @@ * angular controllers and views from the typescript source. | ||
/** | ||
* Default set of [[ModelViewConnector]] which can recognize connections between | ||
* angular models (contained in controller or directives) and views from the typescript source. | ||
* You can give this list in [[ProjectSettings.modelViewConnectors]], or you can add | ||
* your own or provide your own list entirely. | ||
*/ | ||
export declare const defaultModelViewConnectors: ModelViewConnector[]; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare function extractCtrlViewConnsAngularModule(fileName: string, webappPath: string, ctrlViewConnectors: ControllerViewConnector[]): Promise<ViewInfo>; | ||
export declare function extractCtrlViewConnsAngularModule(fileName: string, webappPath: string, ctrlViewConnectors: ControllerViewConnector[], modelViewConnectors: ModelViewConnector[]): Promise<ViewInfo>; | ||
/** | ||
@@ -100,0 +173,0 @@ * @hidden |
@@ -51,2 +51,26 @@ "use strict"; | ||
exports.maybeVariableStatement = maybeNodeType(ts.SyntaxKind.VariableStatement); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeArrowFunction = maybeNodeType(ts.SyntaxKind.ArrowFunction); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeFunctionExpression = maybeNodeType(ts.SyntaxKind.FunctionExpression); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeBlock = maybeNodeType(ts.SyntaxKind.Block); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeReturnStatement = maybeNodeType(ts.SyntaxKind.ReturnStatement); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeAsExpression = maybeNodeType(ts.SyntaxKind.AsExpression); | ||
/** | ||
* @hidden | ||
*/ | ||
exports.maybeArrayLiteralExpression = maybeNodeType(ts.SyntaxKind.ArrayLiteralExpression); | ||
function objectLiteralGetProperty(propName, elts) { | ||
@@ -131,2 +155,54 @@ return elts.find(function (elt) { return exports.maybeIdentifier(elt.name).filter(function (i) { return i.text === propName; }).isSome(); }); | ||
} | ||
function getPropertyByName(objLit, propName) { | ||
return monet_1.Maybe.fromNull(objLit.properties | ||
.find(function (p) { return exports.maybeIdentifier(p.name).filter(function (i) { return i.getText() === propName; }).isSome(); })); | ||
} | ||
function parseAngularDirectiveTemplate(modelPath, callExpr) { | ||
var prop0 = exports.maybePropertyAccessExpression(callExpr.expression); | ||
var prop = prop0 | ||
.flatMap(function (callProp) { return exports.maybeCallExpression(callProp.expression); }) | ||
.flatMap(function (callPropCall) { return exports.maybePropertyAccessExpression(callPropCall.expression); }); | ||
var receiver1 = prop | ||
.flatMap(function (p) { return exports.maybeIdentifier(p.expression); }) | ||
.map(function (r) { return r.text; }); | ||
var call1 = prop | ||
.flatMap(function (p) { return exports.maybeIdentifier(p.name); }) | ||
.map(function (r) { return r.text; }); | ||
if (receiver1.filter(function (v) { return v === "angular"; }) | ||
.orElse(call1.filter(function (v) { return v === "module"; })).isSome()) { | ||
var moduleCall = prop0.map(function (p) { return p.name.text; }); | ||
if (moduleCall.filter(function (v) { return v === "directive"; }).isSome()) { | ||
var directiveParam = monet_1.Maybe.Some(callExpr) | ||
.filter(function (c) { return c.arguments.length > 1; }) | ||
.map(function (c) { return c.arguments[1]; }); | ||
var returnExpr = directiveParam | ||
.flatMap(exports.maybeArrayLiteralExpression) | ||
.filter(function (l) { return l.elements.length > 0; }) | ||
.map(function (l) { return l.elements[l.elements.length - 1]; }) | ||
.orElse(directiveParam); | ||
var arrowBodyExpr = returnExpr | ||
.flatMap(exports.maybeArrowFunction) | ||
.flatMap(function (a) { return exports.maybeBlock(a.body); }); | ||
var fnBodyExpr = returnExpr | ||
.flatMap(exports.maybeFunctionExpression) | ||
.map(function (fn) { return fn.body; }); | ||
var bodyExpr = arrowBodyExpr.orElse(fnBodyExpr); | ||
var resultExpr = bodyExpr | ||
.flatMap(function (b) { return exports.maybeReturnStatement(b.statements[0]); }) | ||
.flatMap(function (s) { return monet_1.Maybe.fromNull(s.expression); }); | ||
var scopeObject = resultExpr | ||
.flatMap(exports.maybeAsExpression) | ||
.map(function (a) { return a.expression; }) | ||
.orElse(resultExpr); | ||
var templateUrl = scopeObject | ||
.flatMap(exports.maybeObjectLiteralExpression) | ||
.flatMap(function (e) { return getPropertyByName(e, "templateUrl"); }) | ||
.flatMap(exports.maybePropertyAssignment) | ||
.flatMap(function (a) { return exports.maybeStringLiteral(a.initializer); }) | ||
.map(function (s) { return s.text; }); | ||
return templateUrl.map(function (viewPath) { return ({ modelPath: modelPath, viewPath: viewPath }); }); | ||
} | ||
} | ||
return monet_1.Maybe.None(); | ||
} | ||
var modalOpenViewConnector = { | ||
@@ -144,2 +220,8 @@ interceptAstNode: ts.SyntaxKind.CallExpression, | ||
}; | ||
var directiveViewConnector = { | ||
interceptAstNode: ts.SyntaxKind.CallExpression, | ||
getModelView: function (filename, node, projectPath) { | ||
return parseAngularDirectiveTemplate(filename, node).toList().toArray(); | ||
} | ||
}; | ||
/** | ||
@@ -153,5 +235,12 @@ * Default set of [[ControllerViewConnector]] which can recognize connections between | ||
/** | ||
* Default set of [[ModelViewConnector]] which can recognize connections between | ||
* angular models (contained in controller or directives) and views from the typescript source. | ||
* You can give this list in [[ProjectSettings.modelViewConnectors]], or you can add | ||
* your own or provide your own list entirely. | ||
*/ | ||
exports.defaultModelViewConnectors = [directiveViewConnector]; | ||
/** | ||
* @hidden | ||
*/ | ||
function extractCtrlViewConnsAngularModule(fileName, webappPath, ctrlViewConnectors) { | ||
function extractCtrlViewConnsAngularModule(fileName, webappPath, ctrlViewConnectors, modelViewConnectors) { | ||
var sourceFile = ts.createSourceFile(fileName, fs_1.readFileSync(fileName).toString(), ts.ScriptTarget.ES2016, /*setParentNodes */ true); | ||
@@ -161,2 +250,3 @@ var ngModuleName = monet_1.Maybe.None(); | ||
var controllerViewInfos = []; | ||
var modelViewInfos = []; | ||
return new Promise(function (resolve, reject) { | ||
@@ -173,6 +263,10 @@ function nodeExtractModuleOpenAngularModule(node) { | ||
.toArray()); | ||
modelViewInfos = modelViewInfos.concat(monet.List.fromArray(modelViewConnectors) | ||
.filter(function (conn) { return conn.interceptAstNode === node.kind; }) | ||
.flatMap(function (conn) { return monet.List.fromArray(conn.getModelView(fileName, node, webappPath)); }) | ||
.toArray()); | ||
ts.forEachChild(node, nodeExtractModuleOpenAngularModule); | ||
} | ||
nodeExtractModuleOpenAngularModule(sourceFile); | ||
resolve({ fileName: fileName, ngModuleName: ngModuleName, controllerName: controllerName, controllerViewInfos: controllerViewInfos }); | ||
resolve({ fileName: fileName, ngModuleName: ngModuleName, controllerName: controllerName, controllerViewInfos: controllerViewInfos, modelViewInfos: modelViewInfos }); | ||
}); | ||
@@ -179,0 +273,0 @@ } |
export { AttributeDirectiveHandler, TagDirectiveHandler, DirectiveResponse, defaultTagDirectiveHandlers, defaultAttrDirectiveHandlers } from "./ng-directives"; | ||
export { ControllerViewInfo, ControllerViewConnector, defaultCtrlViewConnectors } from "./controller-parser"; | ||
export { ControllerViewInfo, ControllerViewConnector, ModelViewConnector, defaultCtrlViewConnectors, defaultModelViewConnectors } from "./controller-parser"; | ||
export { ProjectSettings, processProject } from "./ng-typeview"; | ||
export { NgFilterExpression, NgFilterCall, filterExpressionToTypescript, ngFilterExpressionToTypeScriptEmbedded, ngFilterExpressionToTypeScriptStandalone, parseNgFilterExpression } from "./view-ngexpression-parser"; | ||
export { NgFilter, defaultNgFilters } from "./filters"; |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.defaultCtrlViewConnectors = controller_parser_1.defaultCtrlViewConnectors; | ||
exports.defaultModelViewConnectors = controller_parser_1.defaultModelViewConnectors; | ||
var ng_typeview_1 = require("./ng-typeview"); | ||
@@ -10,0 +11,0 @@ exports.processProject = ng_typeview_1.processProject; |
@@ -27,3 +27,3 @@ "use strict"; | ||
forAttributes: ["ng-click", "ng-model", "ng-change", "ng-value", | ||
"ng-submit", "ng-class", "ng-style", "ng-init"], | ||
"ng-submit", "ng-class", "ng-style", "ng-init", "ng-grid"], | ||
handleAttribute: function (attrName, val, codegenHelpers) { | ||
@@ -33,2 +33,7 @@ return ({ source: codegenHelpers.declareVariable("any", val) }); | ||
}; | ||
// attributes for which we do nothing at all. | ||
var passThroughAttrHandler = { | ||
forAttributes: ["ng-form"], | ||
handleAttribute: function (attrName, val, codegenHelpers) { return ({ source: "" }); } | ||
}; | ||
var stringAttrHandler = { | ||
@@ -142,4 +147,4 @@ forAttributes: ["ng-include", "ng-src"], | ||
}; | ||
var ngBlur = { | ||
forAttributes: ["ng-blur"], | ||
var ngWithEvent = { | ||
forAttributes: ["ng-blur", "ng-mouseenter", "ng-mouseleave"], | ||
handleAttribute: function (attrName, attrValue, codegenHelpers) { | ||
@@ -164,8 +169,2 @@ return { source: "const " + codegenHelpers.getNewVariableName() + " = (" + codegenHelpers.registerVariable('$event') + ": any) => " + | ||
}; | ||
var ngGrid = { | ||
forAttributes: ["ng-grid"], | ||
handleAttribute: function (attrName, attrValue, codegenHelpers) { | ||
return { source: codegenHelpers.declareVariable("any", attrValue) }; | ||
} | ||
}; | ||
// ng-switch should work on the attribute level, but the spec requires to read | ||
@@ -282,2 +281,3 @@ // multiple attributes at once... Eg "on" | ||
} | ||
return undefined; | ||
} | ||
@@ -293,4 +293,4 @@ }; | ||
ngBindAttrDirectiveHandler, | ||
ngRepeatAttrDirectiveHandler, ngOptions, ngBlur, | ||
ngModelOptions, ngPattern, ngGrid]; | ||
ngRepeatAttrDirectiveHandler, ngOptions, ngWithEvent, | ||
ngModelOptions, ngPattern, passThroughAttrHandler]; | ||
/** | ||
@@ -297,0 +297,0 @@ * Set of angular tag directives supported out of the box. You can give this |
import { AttributeDirectiveHandler, TagDirectiveHandler } from "./ng-directives"; | ||
export { AttributeDirectiveHandler, TagDirectiveHandler, defaultTagDirectiveHandlers, defaultAttrDirectiveHandlers } from "./ng-directives"; | ||
import { ControllerViewConnector, ControllerViewInfo } from "./controller-parser"; | ||
import { ControllerViewInfo, ControllerViewConnector, ModelViewConnector } from "./controller-parser"; | ||
import { NgFilter } from "./filters"; | ||
@@ -39,2 +39,11 @@ export { ControllerViewInfo } from "./controller-parser"; | ||
/** | ||
* List of model-view connectors to use. | ||
* These tie model files to views. | ||
* This allows to express non-controller models, such | ||
* as directive models for instance. | ||
* [[defaultModelViewConnectors]] contains a default list; you can use | ||
* that, add to that list, or specify your own. | ||
*/ | ||
modelViewConnectors: ModelViewConnector[]; | ||
/** | ||
* List of tag-bound angular directives to handle during the analysis. | ||
@@ -41,0 +50,0 @@ * [[defaultTagDirectiveHandlers]] contains a default list; you can use |
@@ -108,3 +108,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var files, viewInfos, viewFilenameToControllerNames, controllerNameToFilename, viewFilenameToCtrlFilenames; | ||
var files, viewInfos, viewFilenameToControllerNames, controllerNameToFilename, viewFilenameToCtrlFilenamesViewConns, viewFilenameToCtrlFilenamesModelConns, viewFilenameToCtrlFilenames; | ||
return __generator(this, function (_a) { | ||
@@ -115,3 +115,3 @@ switch (_a.label) { | ||
files = glob_1.sync(prjSettings.path + "/**/*.@(js|ts)", { nodir: true, ignore: prjSettings.blacklistedPaths }); | ||
return [4 /*yield*/, Promise.all(files.map(function (f) { return controller_parser_1.extractCtrlViewConnsAngularModule(f, prjSettings.path, prjSettings.ctrlViewConnectors); }))]; | ||
return [4 /*yield*/, Promise.all(files.map(function (f) { return controller_parser_1.extractCtrlViewConnsAngularModule(f, prjSettings.path, prjSettings.ctrlViewConnectors, prjSettings.modelViewConnectors); }))]; | ||
case 1: | ||
@@ -127,8 +127,15 @@ viewInfos = _a.sent(); | ||
.map(function (vi) { return [vi.controllerName.some(), vi.fileName]; })); | ||
viewFilenameToCtrlFilenames = viewFilenameToControllerNames | ||
viewFilenameToCtrlFilenamesViewConns = viewFilenameToControllerNames | ||
.mapEntries(function (_a) { | ||
var viewFname = _a[0], ctrlViewInfos = _a[1]; | ||
return [viewFname, view_parser_1.collectionKeepDefined(ctrlViewInfos | ||
.map(function (cvi) { return controllerNameToFilename.get(cvi.controllerName); }))]; | ||
}); | ||
return [viewFname, view_parser_1.collectionKeepDefined(ctrlViewInfos.map(function (cvi) { return controllerNameToFilename.get(cvi.controllerName); }))]; | ||
}) | ||
.map(function (v) { return v.toList(); }) | ||
.toMap(); | ||
viewFilenameToCtrlFilenamesModelConns = imm.List(viewInfos) | ||
.flatMap(function (vi) { return vi.modelViewInfos; }) | ||
.groupBy(function (mvi) { return mvi.viewPath; }) | ||
.toMap() | ||
.map(function (mvis) { return mvis.toList().map(function (mvi) { return mvi.modelPath; }); }); | ||
viewFilenameToCtrlFilenames = viewFilenameToCtrlFilenamesViewConns.mergeWith(function (views1, views2) { return views1.concat(views2); }, viewFilenameToCtrlFilenamesModelConns); | ||
return [2 /*return*/, Promise.all(viewFilenameToCtrlFilenames.map(function (ctrlNames, viewName) { return Promise.all(ctrlNames.map(function (ctrlName) { return processControllerView(prjSettings, ctrlName, prjSettings.path + "/" + viewName, prjSettings.ngFilters, prjSettings.tagDirectives, prjSettings.attributeDirectives); }).toArray()); }).toArray())]; | ||
@@ -146,2 +153,3 @@ } | ||
ctrlViewConnectors: controller_parser_1.defaultCtrlViewConnectors, | ||
modelViewConnectors: controller_parser_1.defaultModelViewConnectors, | ||
extraCtrlViewConnections: [], | ||
@@ -148,0 +156,0 @@ tagDirectives: ng_directives_1.defaultTagDirectiveHandlers, |
@@ -234,3 +234,3 @@ "use strict"; | ||
var sourceFile = ts.createSourceFile("", input, ts.ScriptTarget.ES2016, /*setParentNodes */ true); | ||
return sourceFile.statements.map(stmtAddScopeAccessors(scopes)).join(";\n"); | ||
return sourceFile.statements.map(stmtAddScopeAccessors(scopes)).join(""); | ||
} | ||
@@ -307,2 +307,5 @@ exports.addScopeAccessors = addScopeAccessors; | ||
} | ||
else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) { | ||
return "[" + node.elements.map(stmtAddScopeAccessors(scopes)).join(", ") + "]"; | ||
} | ||
console.log("Add scope accessors: unhandled node: " + node.kind + " -- " + node.getText()); | ||
@@ -309,0 +312,0 @@ return node.getText(); |
@@ -68,3 +68,3 @@ "use strict"; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, controller_parser_1.extractCtrlViewConnsAngularModule("test/data/test-ctrl.ts", "webapp", controller_parser_1.defaultCtrlViewConnectors.concat([ctrlViewConn]))]; | ||
case 0: return [4 /*yield*/, controller_parser_1.extractCtrlViewConnsAngularModule("test/data/test-ctrl.ts", "webapp", controller_parser_1.defaultCtrlViewConnectors.concat([ctrlViewConn]), controller_parser_1.defaultModelViewConnectors)]; | ||
case 1: | ||
@@ -71,0 +71,0 @@ modalModuleInfo = _a.sent(); |
@@ -51,3 +51,3 @@ "use strict"; | ||
it("should generate view test files", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var actualContents, expectedContents; | ||
var actualContents, expectedContents, actualContentsDirective, expectedContentsDirective, actualContentsDirective2, expectedContentsDirective2, actualContentsDirective3, expectedContentsDirective3, actualContentsDirective4, expectedContentsDirective4; | ||
return __generator(this, function (_a) { | ||
@@ -62,2 +62,3 @@ switch (_a.label) { | ||
ctrlViewConnectors: controller_parser_1.defaultCtrlViewConnectors, | ||
modelViewConnectors: controller_parser_1.defaultModelViewConnectors, | ||
extraCtrlViewConnections: [], | ||
@@ -72,2 +73,14 @@ tagDirectives: ng_directives_1.defaultTagDirectiveHandlers, | ||
assert.equal(expectedContents, actualContents); | ||
actualContentsDirective = fs_1.readFileSync("test/data/test-directive_directive-template_viewtest.ts").toString(); | ||
expectedContentsDirective = fs_1.readFileSync("test/data/expected_directive_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective, actualContentsDirective); | ||
actualContentsDirective2 = fs_1.readFileSync("test/data/test-directive2_directive-template_viewtest.ts").toString(); | ||
expectedContentsDirective2 = fs_1.readFileSync("test/data/expected_directive2_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective2, actualContentsDirective2); | ||
actualContentsDirective3 = fs_1.readFileSync("test/data/test-directive3_directive-template_viewtest.ts").toString(); | ||
expectedContentsDirective3 = fs_1.readFileSync("test/data/expected_directive3_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective3, actualContentsDirective3); | ||
actualContentsDirective4 = fs_1.readFileSync("test/data/test-directive4_directive-template_viewtest.ts").toString(); | ||
expectedContentsDirective4 = fs_1.readFileSync("test/data/expected_directive4_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective4, actualContentsDirective4); | ||
return [2 /*return*/]; | ||
@@ -74,0 +87,0 @@ } |
@@ -34,4 +34,6 @@ "use strict"; | ||
assertScopeAcc("/^[a-z]+$/", "/^[a-z]+$/"); | ||
// yes, that next one is pretty horrific. actually spotted that in the wild. | ||
assertScopeAcc("{true:'glyphicon-chevron-up' , false:'glyphicon-chevron-down'}[$scope.showList]", "{true:'glyphicon-chevron-up', false:'glyphicon-chevron-down'}[showList]"); | ||
}); | ||
}); | ||
//# sourceMappingURL=view-ngexpression-parser.js.map |
{ | ||
"name": "ng-typeview", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "library to enable type-checking of angular views when using typescript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,4 @@ import * as assert from 'assert' | ||
extractCtrlViewConnsAngularModule, | ||
ControllerViewInfo, defaultCtrlViewConnectors} from '../src/controller-parser' | ||
ControllerViewInfo, | ||
defaultCtrlViewConnectors, defaultModelViewConnectors} from '../src/controller-parser' | ||
import * as ts from "typescript"; | ||
@@ -32,3 +33,5 @@ | ||
const modalModuleInfo = await extractCtrlViewConnsAngularModule( | ||
"test/data/test-ctrl.ts", "webapp", defaultCtrlViewConnectors.concat([ctrlViewConn])); | ||
"test/data/test-ctrl.ts", "webapp", | ||
defaultCtrlViewConnectors.concat([ctrlViewConn]), | ||
defaultModelViewConnectors); | ||
assert.equal("test/data/test-ctrl.ts", modalModuleInfo.fileName); | ||
@@ -35,0 +38,0 @@ assert.deepEqual(Maybe.Some("my.ng.module.name"), modalModuleInfo.ngModuleName); |
@@ -6,3 +6,3 @@ import * as assert from 'assert' | ||
import {NgFilter, defaultNgFilters} from "../src/filters" | ||
import {defaultCtrlViewConnectors} from "../src/controller-parser" | ||
import {defaultCtrlViewConnectors, defaultModelViewConnectors} from "../src/controller-parser" | ||
import {defaultTagDirectiveHandlers, defaultAttrDirectiveHandlers} from "../src/ng-directives" | ||
@@ -19,4 +19,5 @@ | ||
blacklistedPaths: [], | ||
ngFilters :filters, | ||
ngFilters: filters, | ||
ctrlViewConnectors: defaultCtrlViewConnectors, | ||
modelViewConnectors: defaultModelViewConnectors, | ||
extraCtrlViewConnections: [], | ||
@@ -28,3 +29,19 @@ tagDirectives: defaultTagDirectiveHandlers, | ||
assert.equal(expectedContents, actualContents); | ||
const actualContentsDirective = readFileSync("test/data/test-directive_directive-template_viewtest.ts").toString(); | ||
const expectedContentsDirective = readFileSync("test/data/expected_directive_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective, actualContentsDirective); | ||
const actualContentsDirective2 = readFileSync("test/data/test-directive2_directive-template_viewtest.ts").toString(); | ||
const expectedContentsDirective2 = readFileSync("test/data/expected_directive2_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective2, actualContentsDirective2); | ||
const actualContentsDirective3 = readFileSync("test/data/test-directive3_directive-template_viewtest.ts").toString(); | ||
const expectedContentsDirective3 = readFileSync("test/data/expected_directive3_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective3, actualContentsDirective3); | ||
const actualContentsDirective4 = readFileSync("test/data/test-directive4_directive-template_viewtest.ts").toString(); | ||
const expectedContentsDirective4 = readFileSync("test/data/expected_directive4_testview.ts").toString(); | ||
assert.equal(expectedContentsDirective4, actualContentsDirective4); | ||
}); | ||
}); |
@@ -42,3 +42,6 @@ import * as assert from 'assert' | ||
assertScopeAcc("/^[a-z]+$/", "/^[a-z]+$/"); | ||
// yes, that next one is pretty horrific. actually spotted that in the wild. | ||
assertScopeAcc("{true:'glyphicon-chevron-up' , false:'glyphicon-chevron-down'}[$scope.showList]", | ||
"{true:'glyphicon-chevron-up', false:'glyphicon-chevron-down'}[showList]"); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
202497
2708