In the unit test ComponentA-test I would like to trigger the function load() in ComponentA, but I have problems doing so.
Before the assert.equal in the below code example I would like to add something simular to this.load() that I would have written in the component to trigger it. But I can't seem to find the right syntax for doing so.
test('should render some information', async function (assert)) {
await render(hbs`{{componentA}}`);
assert.euqal(".info").text().trim(), "info text");
}
There's a couple things you can do here but it depends on whether
loadis an action or not. There may be other ways to test this as well, but these are the most common methods I use.If
loadis an action and is triggered by a DOM event (i.e., clicking a button) then you can trigger the function by performing that DOM event in your integration test:If it's simply a regular function in the component and you want to call this function manually on an instance of the component you could try doing so in a component unit test. The only gotcha here is that you won't be able to assert any DOM changes.