Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Tests #5

Closed
cranberryofdoom opened this issue Feb 11, 2019 · 1 comment
Closed

Unit Tests #5

cranberryofdoom opened this issue Feb 11, 2019 · 1 comment

Comments

@cranberryofdoom
Copy link

Hey! This is really neat-- I ran into the same issue and used the snippet of your code to layout the items in my CSS Grid properly.

I also wrote some unit tests, if you'd like to use them.

describe('reorder', function () {
    it('should reorder successfully when rows are divisible', function () {
      const initialArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
      const endArray = [0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11];
      expect(reorder(initialArray, 3)).to.have.ordered.members(endArray);
    });
    it('should reorder successfully when rows are not evenly divisible', function () {
      const initialArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
      const endArray = [0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8];
      expect(reorder(initialArray, 3)).to.have.ordered.members(endArray);
    });
    it('should return the same array if num columns are less than array length', function () {
      const initialArray = [0, 1, 2, 3, 4];
      const endArray = [0, 1, 2, 3, 4];
      expect(reorder(initialArray, 5)).to.have.ordered.members(endArray);
    });
  });
@jessekorzan
Copy link
Owner

@cranberryofdoom thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants