Как создать фиктивный объект для проверки кода в TestComponent? Вот что у меня есть: Когда я запускаю, он говорит: «Ошибка типа: Не удается прочитать свойство» inner HTML 'null'
app. js
<template>
<compose view-model="./component/TestComponent" model.bind="TestData"></compose>
</template>
TestComponent. html
<template>
<div class="menuItem">
<h4>ID: ${data.menu.id}</h4>
<div class="value">${data.menu.value}</div>
<div class="path">${data.menu.path}</div>
</div>
<template>
TestComponent.spe c. js
import {StageComponent} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrapper';
describe('TestComponent', () => {
let component;
beforeEach(() => {
component = StageComponent
.withResources('component/TestComponent')
.inView('<TestComponent></TestComponent>')
.boundTo({"menu": {"id": "3", "value": "Sample", "path": "Middle"}});
});
it('should render value', done => {
component.create(bootstrap).then(() => {
const nameElement = document.querySelector('.value');
expect(nameElement.innerHTML).toBe('Sample');
done();
}).catch(e => { console.log(e.toString()) });
});
afterEach(() => {
component.dispose();
});
});
Макет данных:
{"menu": {
"id": "3",
"value": "Sample",
"path": "Middle"
}}