Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. // TODO: Add your tests here
  2. // Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework.
  3. // [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework)
  4. // are still available for now.
  5. //
  6. // For new tests, using [Chai](https://chaijs.com/) is recommended.
  7. // You can use it by requiring:
  8. // const assert = require("chai").assert;
  9. // If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.
  10.  
  11. describe("Solution", function() {
  12. it("should test that a user is initialized correctly", function() {
  13. var user = new User();
  14. Test.assertEquals(user.rank, -8);
  15. Test.assertEquals(user.progress, 0);
  16. });
  17.  
  18. it("should test that a user gets proper progress", function() {
  19. var user = new User();
  20. user.rank = -6;
  21. user.incProgress(-6);
  22. Test.assertEquals(user.progress, 3);
  23. user.incProgress(-7);
  24. Test.assertEquals(user.progress, 4);
  25. user.incProgress(-8);
  26. Test.assertEquals(user.progress, 4);
  27. user.incProgress(-5);
  28. Test.assertEquals(user.progress, 14);
  29. user.incProgress(-4);
  30. Test.assertEquals(user.progress, 54);
  31. });
  32.  
  33. it("should increase level appropriately ", function() {
  34. var user = new User();
  35. user.incProgress(-4);
  36. Test.assertEquals(user.progress, 60);
  37. Test.assertEquals(user.rank, -7);
  38. user.incProgress(-2);
  39. Test.assertEquals(user.progress, 10);
  40. Test.assertEquals(user.rank, -4);
  41. });
  42.  
  43. it("shouldn't increase rank above 8 and just keep increasing progress", function() {
  44. var user = new User();
  45. user.incProgress(8);
  46. Test.assertEquals(user.progress, 0);
  47. Test.assertEquals(user.rank, 8);
  48. });
  49. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement