Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TODO: Add your tests here
- // Starting from Node 10.x, [Mocha](https://mochajs.org) is used instead of our custom test framework.
- // [Codewars' assertion methods](https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework)
- // are still available for now.
- //
- // For new tests, using [Chai](https://chaijs.com/) is recommended.
- // You can use it by requiring:
- // const assert = require("chai").assert;
- // If the failure output for deep equality is truncated, `chai.config.truncateThreshold` can be adjusted.
- describe("Solution", function() {
- it("should test that a user is initialized correctly", function() {
- var user = new User();
- Test.assertEquals(user.rank, -8);
- Test.assertEquals(user.progress, 0);
- });
- it("should test that a user gets proper progress", function() {
- var user = new User();
- user.rank = -6;
- user.incProgress(-6);
- Test.assertEquals(user.progress, 3);
- user.incProgress(-7);
- Test.assertEquals(user.progress, 4);
- user.incProgress(-8);
- Test.assertEquals(user.progress, 4);
- user.incProgress(-5);
- Test.assertEquals(user.progress, 14);
- user.incProgress(-4);
- Test.assertEquals(user.progress, 54);
- });
- it("should increase level appropriately ", function() {
- var user = new User();
- user.incProgress(-4);
- Test.assertEquals(user.progress, 60);
- Test.assertEquals(user.rank, -7);
- user.incProgress(-2);
- Test.assertEquals(user.progress, 10);
- Test.assertEquals(user.rank, -4);
- });
- it("shouldn't increase rank above 8 and just keep increasing progress", function() {
- var user = new User();
- user.incProgress(8);
- Test.assertEquals(user.progress, 0);
- Test.assertEquals(user.rank, 8);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement