February 2019
Beginner
694 pages
18h 4m
English
We can use the same techniques to test that complex models are instantiated correctly. Consider the following test suite:
describe("model.spec.ts : ItemCollectionViewModel tests", () => {
let itemCollectionViewModel: ItemCollectionViewModel;
beforeEach(() => {
itemCollectionViewModel = new ItemCollectionViewModel({
Title: "testTitle",
SelectedItem: {
Id: 10,
DisplayName: "testDisplayName"
},
Name: "testName"
});
});
Here, we are creating an instance of our complex model, named itemCollectionViewModel. The interesting bit is the construction of this complex model with a POJO. We are calling the constructor in our beforeEach function, and simply nesting POJOs within each other. We are setting the Title property, and then ...
Read now
Unlock full access