The following test works (using http://mochajs.org + http://chaijs.com):
The following test fails:
How can I at least test that viewModel.item.attributes is an observable? Otherwise what instance of is it?
it(
'Test composition'
,
function
() {
var
viewModel = kendo.observable({
obj1: {
obj2: {
prop:
'test'
}
}
});
expect(viewModel).to.be.an.
instanceof
(kendo.Observable);
expect(viewModel.obj1).to.be.an.
instanceof
(kendo.Observable);
expect(viewModel.obj1.obj2).to.be.an.
instanceof
(kendo.Observable);
});
The following test fails:
it(
'Test submodels'
,
function
() {
var
Item = kendo.data.Model.define({
fields: {
title: {
type:
'string'
},
attributes: {
defaultValue: {}
}
}
});
var
Attributes = kendo.data.Model.define({
fields: {
src: {
type:
'string'
},
alt: {
type:
'string'
},
style: {
type:
'string'
}
}
});
var
attributes =
new
Attributes({alt:
'Google'
, src:
'http://www.google.com/logo.jpg'
, style:
'height: 100px; width: 100px;'
}),
item =
new
Item({title:
'sample image'
, attribute: attributes}),
viewModel = kendo.observable({ item: item });
expect(viewModel.item).to.be.an.
instanceof
(Item);
expect(viewModel.item).to.be.an.
instanceof
(kendo.data.Model);
expect(viewModel.item).to.be.an.
instanceof
(kendo.Observable);
expect(viewModel.item.attributes).to.be.an.
instanceof
(Attributes);
//Fails
expect(viewModel.item.attributes).to.be.an.
instanceof
(kendo.data.Model);
//Fails
expect(viewModel.item.attributes).to.be.an.
instanceof
(kendo.Observable);
//Fails
});
How can I at least test that viewModel.item.attributes is an observable? Otherwise what instance of is it?