Code Snippets

Two Tools for Sproutcore Testing

Here are two tools that can help test their Sproutcore functions in a controlled enviornment. More information can be found in this blog post.

Jasmine provides an environment to test.

it("Should see login pane", function() {
  ...
  expect(loginPane.isPaneAttached).toBeTruthy();
});

Simulo allows us to simulate a user action such as fill in a text field, or click a button. This comes in handy for testing logins or forms. Simulo does this by using selectors like CSS and jQuery.

it("Test login fields", function() {
  //get variables
  if (email != 'someone@something.com') {
    App.signInViewController.set('email', '');
    Simulo.fillIn('.signin-username input', 'someone@something.com');
  }
  
  if (pass != '') {
    App.signInViewController.set('password', '');
    Simulo.fillIn('.signin-password input', 'p@ssw0rd');
  }
    
  Simulo.clickOn('.form-button');
});

 

Resource Tags: