模拟图像文件对象

时间:2016-01-06 15:08:59

标签: javascript angularjs mocking karma-runner karma-mocha

我正在为我们的角应用程序中的裁剪工具集成编写测试。

如何根据我需要的src或本地文件模拟图像文件对象?

我正在使用Karma,Mocha,Chai&诗乃 - 这就是iv得到了多远

describe('cropping tool', function() {
    var scope;
    var $compile;
    var $rootScope;
    var $templateCache;

    beforeEach(function() {
        module(
            'app',
            'modules/croptool/croptool.html',
            'modules/croptool/croptool.test.html'
        );

        angular.mock.module('ngMockE2E');

        inject(function(_$compile_, _$rootScope_, _$templateCache_) {
            $compile = _$compile_;
            $rootScope = _$rootScope_;
            $templateCache = _$templateCache_;
        });

        scope = $rootScope;
    });

    it('should validate that it loads the image into the cropper', function() {
        var template = $templateCache.get('modules/croptool/croptool.test.html');
        var element = angular.element(template);

        var directiveElem = getCompiledElement(element);
        var vm = element.isolateScope();

        // Expect the predefined value

        // Click the toggle button
    });

    // Helper function
    function getCompiledElement(template) {
        var compiledDirective = $compile(angular.element(template))(scope);
        scope.$digest();
        return compiledDirective;
    }

    function ae(element) {
        return angular.element(element);
    }
});

0 个答案:

没有答案