Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. t.test('--Scenario: save error (stubbed) [failure]', function (st) {
  2. st.plan(1);
  3.  
  4. const userData = {
  5. email: 'valid@example.com',
  6. password: 'longpassword'
  7. };
  8. const user = User.forge(userData);
  9.  
  10. const stub = sinon.stub(user, 'save', function () {
  11. throw Error('stubbed error');
  12. });
  13.  
  14. return Promise.try(function () {
  15. return user.register();
  16. }).catch(function (error) {
  17. st.equal(
  18. error.message,
  19. 'stubbed error',
  20. 'should respond with stubbed error'
  21. );
  22. stub.restore();
  23. });
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement