es-bootstrap.js 646 B

12345678910111213141516171819
  1. /* global chai */
  2. /**
  3. * Add chai assertion for comparing CodeMirror Pos objects.
  4. * A deep comparison will fail because CodeMirror inserts additional properties
  5. * that we want to ignore.
  6. */
  7. chai.Assertion.addMethod('equalPos', function (expectedPos) {
  8. const { line: actualLine, ch: actualCh } = this._obj
  9. const { line: expectedLine, ch: expectedCh } = expectedPos
  10. this.assert(
  11. actualLine === expectedLine && actualCh === expectedCh,
  12. `expected #{exp} to equal #{act}`,
  13. `expected #{exp} to not equal #{act}`,
  14. `Pos({ line: ${expectedLine}, ch: ${expectedCh} })`,
  15. `Pos({ line: ${actualLine}, ch: ${actualCh} })`
  16. )
  17. })