小编Rap*_*ael的帖子

Karma测试:TypeError:尝试分配给readonly属性

当我尝试对我的控制器进行单元测试时,我收到了错误.当我调试测试用例时,我希望得到预期的值,但是它失败了以下错误.我在这里丢失的是什么,或者我是否在错误中测试控制器变量方式?

我的spec文件如下

'use strict';
describe('Information.controller', function () {
beforeEach(angular.mock.module('asp'));
var InformationController, scope;

beforeEach(inject(function($controller, $rootScope) {
    scope = $rootScope.$new();
    InformationController = $controller('InformationController', {
        $scope: scope
    });
}));

fit('Should remove the object without info from the  object', function () {
    InformationController.Data = [
        {
            "ban": "03745645455",
            "accountNo": "0000drgyt456456565",
            "id": "2c4cc5e8-f360367"
        },
        {
            "ban": "27346fgh9080",
            "accountNo": "000456456ytr655680",
            "id": "2c4cc8ae-50bbf360367"
        }
    ];
    InformationController.banList = InformationController.Data.map((value, index) => (value && value.ban ? {'id': index, 'text': value.ban} : null))
    .filter(value => value);
    expect(InformationController.banList.length).toBe(3);
});
});
Run Code Online (Sandbox Code Playgroud)

unit-testing angularjs angularjs-controller karma-jasmine

24
推荐指数
1
解决办法
4万
查看次数

未捕获的引用错误:ClassicEditor 未定义(ckeditor5)

我正在尝试在本地设置 ckeditor5 但遇到此错误

\n\n
\n

未捕获的语法错误:无效或意外的标记\n example.html:14 未捕获的引用错误:未定义 ClassicEditor

\n
\n\n

下面是本地代码。

\n\n
<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>CKEditor 5 \xe2\x80\x93 Classic editor</title>\n<script src="ckeditor1.js"></script>\n</head>\n<body>\n<h1>Classic editor</h1>\n<textarea name="content" id="editor">\n    &lt;p&gt;This is some sample content.&lt;/p&gt;\n</textarea>\n<script>\n    ClassicEditor\n        .create( document.querySelector( \'#editor\' ) )\n        .catch( error => {\n            console.error( error );\n        } );\n</script>\n</body>\n</html>\n
Run Code Online (Sandbox Code Playgroud)\n\n

但当我指向 cdn ckeditor url 时,同样有效:

\n\n
https://cdn.ckeditor.com/ckeditor5/12.3.0/classic/ckeditor.js\n
Run Code Online (Sandbox Code Playgroud)\n\n

工作 CDN jsfiddle

\n

javascript ckeditor5

5
推荐指数
1
解决办法
2万
查看次数

使用ES6语法在.map()中添加条件检查时出错

我只需要将包含iban值的对象分配给下面代码中的列表.我无法解决此问题.善意的帮助.

  this.ibanList = this.data.map(
        (value, index)=> (if(value && value.iban){'id': index, 'text': value.iban}));
Run Code Online (Sandbox Code Playgroud)

数据中存在的值如下所示.

 "data": [
        {

            "id": "2c4cc5e8-d24d-11e4-8833-150bbf360367"
        },
        {
            "iban": "DE45765459080",
            "id": "2c4cc8ae-d24d-11e4-8833-150bbf360367"
        },
        {

            "iban": "DE3700333333",
            "id": "8a23995d-10d7-11e5-b819-2c44fd83fb24"
        }
    ]
Run Code Online (Sandbox Code Playgroud)

javascript callback angularjs ecmascript-6

1
推荐指数
1
解决办法
142
查看次数