내가 업데이트 내 테스트하고 돌아 오는 오류 메시지가 매우 혼란 때문에했습니다 ...재스민 테스트 녹아웃 ObservableArray
it('Should get the available databases', function() {
expect(vm.databases).toEqual([
{
name: 'DB 1',
chosenRoles: function() { return []; },
chosenModules: function() { return []; }
},
{
name: 'DB 2',
chosenRoles: function() { return []; },
chosenModules: function() { return []; }
},
{
name: 'DB 3',
chosenRoles: function() { return []; },
chosenModules: function() { return []; }
},
{
name: 'DB 4',
chosenRoles: function() { return []; },
chosenModules: function() { return []; }
},
{
name: 'DB 5',
chosenRoles: function() { return []; },
chosenModules: function() { return []; }
}
]);
});
Summary (1 tests failed)
x User Management Initial state Should get the available databases
Expected [ { name : 'DB 1', chosenRoles : Function, chosenModules : Functi
}, { name : 'DB 2', chosenRoles : Function, chosenModules : Function }, { nam
: 'DB 3', chosenRoles : Function, chosenModules : Function }, { name : 'DB 4',
hosenRoles : Function, chosenModules : Function }, { name : 'DB 5', chosenRole
: Function, chosenModules : Function } ] to equal [ { name : 'DB 1', chosenRol
: Function, chosenModules : Function }, { name : 'DB 2', chosenRoles : Functi
, chosenModules : Function }, { name : 'DB 3', chosenRoles : Function, chosenM
ules : Function }, { name : 'DB 4', chosenRoles : Function, chosenModules : Fu
tion }, { name : 'DB 5', chosenRoles : Function, chosenModules : Function } ].
원래의 게시물
나는를
업데이트 Jasmine Tests를 실행하는 데 새로운 것이므로 쉬운 질문 일 수 있지만 상황에 맞는 것을 찾을 수는 없습니다.
각 오브젝트에서 두 개의 녹아웃 observableArray()가있는 배열에서 밑줄을 사용하여 다섯 개의 오브젝트 목록을 만듭니다.
var pfp = pfp || {};
pfp.insight = pfp.insight || {};
pfp.insight.controllers = pfp.insight.controllers || {};
(function() {
'use strict';
this.settingsController = function() {
var root = this;
root.databases = _.range(5).map(function (i) {
return {
name: 'DB ' + (i + 1),
chosenRoles: ko.observableArray(),
chosenModules: ko.observableArray()
};
});
};
}).call(pfp.insight.controllers);
나는 데이터베이스 배열의 초기 상태를 확인하는 단위 테스트를 작성하는 방법을 정확히 모르겠습니다. 나는이 문제를 추측 할
describe('User Management', function() {
'use strict';
var vm,
databases = [];
describe('Initial state', function() {
beforeEach(function() {
vm = new pfp.insight.controllers.settingsController();
});
it('Should get the available databases', function() {
expect(vm.databases).toEqual([
{
name: 'DB 1',
chosenRoles: [],
chosenModules: []
},
{
name: 'DB 2',
chosenRoles: [],
chosenModules: []
},
{
name: 'DB 3',
chosenRoles: [],
chosenModules: []
},
{
name: 'DB 4',
chosenRoles: [],
chosenModules: []
},
{
name: 'DB 5',
chosenRoles: [],
chosenModules: []
}
]);
});
});