Factorize something which can be both a given and a when

5 views
Skip to first unread message

Fabien Tregan

unread,
Apr 5, 2014, 3:38:17 PM4/5/14
to jasmi...@googlegroups.com
Hi,

  I'm learning Jasmine. In my tests, I try to use something like :

it("should be logged after login", function() {

  given.aNewUser();

  when.userLogsin();

  then.userIsLogged();

)};

That's easy. But if in next behaviour I need a logged-in user, I do :

it("should be unlogged after unlogin", function() {

  given.aUser();
  given.userLoggedin();

  when.userUnlogs();

  then.not(userIsLogged);
}

where given.userLoggedIn() = when.userLogsIn() . I think I can use it as a "given" since it has already been tested as a "when" in previous test. Does I do it the right way ?

Thank you,
Fabien.
Reply all
Reply to author
Forward
0 new messages