这是我的功能
$scope.buildForm = function (majorObjectId, name) {
$window.open("/FormBuilder/Index#/" + $scope.currentAppId + "/form/" + majorObjectId + "/" + name);
};
Run Code Online (Sandbox Code Playgroud)
这是我的茉莉花测试规范
it('should open new window for buildForm and with expected id', function () {
scope.majorObjectId = mockObjectId;
scope.currentAppId = mockApplicationId;
var name = "DepartmentMajor";
scope.buildForm(mockObjectId, name);
scope.$digest();
expect(window.open).toHaveBeenCalled();
spyOn(window, 'open');
spyOn(window, 'open').and.returnValue("/FormBuilder/Index#/" + scope.currentAppId + "/form/" + scope.majorObjectId + "/" + name);
});
Run Code Online (Sandbox Code Playgroud)
但当我尝试运行它时,它打开一个新选项卡,我不希望这发生,我只是想检查给定的returnValues是否存在不!
这是我的代码
<rule name="adding Id after PortNumber" patternSyntax="Wildcard" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="{HTTP_HOST}/12312312" negate="true"/>
</conditions>
<action type="Redirect" url="{HTTP_HOST}/{R:1}"/>
</rule>
Run Code Online (Sandbox Code Playgroud)
这是我的route.config
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"ApplicationRoute",
"{appId}/{controller}/{action}/{id}",
new { controller = "Account", action = "SignIn", id = UrlParameter.Optional },
new {
isValidAppId = new isValidAppId()
}
);
}
}
public class isValidAppId : IRouteConstraint
{
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
var isValid = …Run Code Online (Sandbox Code Playgroud) 我有一个图像,需要通过拖动角来调整大小,angularjs中有任何选项吗?
截至目前我正在做手动图像调整大小如下:
<img src="~/Content/images/login-logo.png" width="{{image.width}}" height="{{image.size}}"/>
<div class="right-wrapper">
<h3 class="right-head">Appearance <img src="~/Content/images/info-icon.png"></h3>
<div ng-if="isImage">
<div ng-class="form-group">
size
<input class="form-control" type="textbox" ng-model="image.size" />
</div>
<div ng-class="form-group">
width
<input class="form-control" type="textbox" ng-model="image.width" />
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但是我想通过拖动它来调整它的大小.
这是我的控制器代码
$scope.aceOptions = {
workerPath: 'http://localhost:50871/Scripts/app/vendor/',
useWrapMode: true,
showGutter: true,
theme: 'chrome',
firstLineNumber: 1,
onLoad: function (_editor) {
$scope.script = {};
$scope.script.scriptCode = "function fieldName_columnName_" + "functionName(){\n\n\n}";
var _session = _editor.getSession();
_session.setMode('ace/mode/javascript');
var _renderer = _editor.renderer;
_session.on('changeAnnotation', function () {
$scope.annotations = [];
$scope.annotations = _editor.getSession().getAnnotations();
}),
_editor.$blockScrolling = Infinity;
_session.on("change", function (e) {
var currentValue = _editor.getSession().getValue();
$scope.script.scriptCode = currentValue;
});
},
require: ['ace/ext/language_tools'],
advanced: {
enableSnippets: true,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true
}
}
Run Code Online (Sandbox Code Playgroud)
我为ui-ace写了指令这是我的html代码
<javascript-editor code="script.scriptCode" ace-option="aceOptions"></javascript-editor>
Run Code Online (Sandbox Code Playgroud)
和指令代码是 …
javascript angularjs angularjs-directive angularjs-scope angularjs-ng-repeat
这是我的控制器代码
$scope.loadApplications = function () {
var cacheKey = { key: cacheKeys.appList() };
dataFactory.get("/Application/All", { cache: cacheKey })
.then(function (result) {
$scope.count++;
$scope.applications = result.data.data;
$scope.filteredApplicationsList = $scope.applications;
if ($scope.applications.length===0){
$window.location.href = '/Account/WelCome'
}
else {
$scope.isLoad = true;
}
});
};
Run Code Online (Sandbox Code Playgroud)
这是我对上述功能的茉莉花测试用例
it('should redirect to welcome page', function () {
scope.applications = {};
scope.loadApplications();
expect(window.location.href).toContain('/Account/WelCome');
});
Run Code Online (Sandbox Code Playgroud)
但它正在获取浏览器的当前URL,并且它正在引发错误
Expected 'http://localhost:49363/Scripts/app/test/SpecRunner.html' to contain '/Account/WelCome'.
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何测试网址?