ranges-tracker-test.js 983 B

1234567891011121314151617181920212223242526272829
  1. const { expect } = require('chai')
  2. const RangesTracker = require('../..')
  3. describe('RangesTracker', function () {
  4. describe('with duplicate change ids', function () {
  5. beforeEach(function () {
  6. this.changes = [
  7. { id: 'id1', op: { p: 1, i: 'hello' } },
  8. { id: 'id2', op: { p: 10, i: 'world' } },
  9. { id: 'id3', op: { p: 20, i: '!!!' } },
  10. { id: 'id1', op: { p: 30, d: 'duplicate' } },
  11. ]
  12. this.rangesTracker = new RangesTracker(this.changes, this.comments)
  13. })
  14. it('getChanges() returns all changes with the given ids', function () {
  15. expect(this.rangesTracker.getChanges(['id1', 'id2'])).to.deep.equal([
  16. this.changes[0],
  17. this.changes[1],
  18. this.changes[3],
  19. ])
  20. })
  21. it('removeChangeIds() removes all changes with the given ids', function () {
  22. this.rangesTracker.removeChangeIds(['id1', 'id2'])
  23. expect(this.rangesTracker.changes).to.deep.equal([this.changes[2]])
  24. })
  25. })
  26. })