viewmodel-react icon indicating copy to clipboard operation
viewmodel-react copied to clipboard

Expose View Model methods using Jest

Open sirganya opened this issue 6 years ago • 3 comments

Is there a recommended strategy for importing a viewmodel into a Jest test and exposing it's methods for unit testing?

sirganya avatar May 08 '18 14:05 sirganya

Import { YourComponent } from "./YourComponent"; Const yourComponent = new yourComponent();

See the testing section of the docs in basics and advanced.

On Tue, May 8, 2018, 8:13 AM Greg Kavanagh [email protected] wrote:

Is there a recommended strategy for importing a viewmodel into a Jest test and exposing it's methods for unit testing?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel-react/issues/43, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31gC-6adCeHmN4PEO0LFuN9zw_UBaks5twafwgaJpZM4T2uLd .

ManuelDeLeon avatar May 08 '18 14:05 ManuelDeLeon

I should have specified that I'm using Blaze. Should it work similarly?

sirganya avatar May 08 '18 14:05 sirganya

Ah, almost the same way. With

var vm = Template.name.createViewModel();
var vm = Template.name.createViewModel(obj_with_propreties_passed_down_to_template);

See the testing part of the PhoneBook example project: https://github.com/ManuelDeLeon/phonebook/tree/master/tests/mocha/client/viewmodels

ManuelDeLeon avatar May 08 '18 14:05 ManuelDeLeon