Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 剑道可排序+业力:单元测试提示功能_Javascript_Angularjs_Kendo Ui_Karma Runner_Karma Jasmine - Fatal编程技术网

Javascript 剑道可排序+业力:单元测试提示功能

Javascript 剑道可排序+业力:单元测试提示功能,javascript,angularjs,kendo-ui,karma-runner,karma-jasmine,Javascript,Angularjs,Kendo Ui,Karma Runner,Karma Jasmine,我有一个剑道排序的现有案例,我正在尝试使用karma和jasmine测试提示函数。关于如何使用剑道可排序来模拟拖动事件以便调用提示函数,有什么想法吗 $element.find("#sortable-container").kendoSortable({ axis: "none", cursor: "move", container: "#sortable-container", hint: function (element) { //this is not c

我有一个剑道排序的现有案例,我正在尝试使用karma和jasmine测试提示函数。关于如何使用剑道可排序来模拟拖动事件以便调用提示函数,有什么想法吗

$element.find("#sortable-container").kendoSortable({
    axis: "none",
    cursor: "move",
    container: "#sortable-container",
    hint: function (element) { //this is not called and is messing with my karma coverage
        var elementHint = element.clone();

        elementHint.find('[ng-transclude=""]').removeAttr("ng-transclude");
        elementHint.find(".hw-closeable").removeClass("hw-closeable");

        return elementHint.addClass("sortable-tooltip");
    }
});

对于单元测试,手动调用提示函数对我来说已经足够好了。我同意,对于集成测试,需要一些更高级的东西

我的代码如下所示:

指示

指令HTML

业力测验

angular.module('appSample').directive('sortableDiv', function () {
    return {
        restrict: 'A',
        transclude: true,
        templateUrl: 'src/widgets/sortable-div/sortable-div.html',
        controller: function ($scope, $element) {
            $element.find("#sortable-container").kendoSortable({
                axis: "none",
                cursor: "move",
                container: "#sortable-container",
                hint: function (element) {
                    return element.clone().addClass("sortable-tooltip");
                }
            });
        }
    };
});
<div id="sortable-container" class="row sortable-container" ng-transclude></div>
function sortableDiv() {
    var el = angular.element('<div sortable-div><div id="sort1">Sort me!</div> <div id="sort2">Sort me again!</div></div>');

    compile(el)(scope);

    scope.$digest();
    timeout.flush();

    return el;
}

it('should hint a sortable div', function () {

    var el = sortableDiv();

    var elHint = el.find("#sortable-container").data("kendoSortable").options.hint(el.find("#sort1"));

    expect(elHint.attr("class")).toContain("sortable-tooltip");
});