mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-23 14:13:26 +00:00
Add custom assertion method to chai for comparing CM Pos objects
This commit is contained in:
parent
9f5e976539
commit
3a90a2d004
2 changed files with 20 additions and 0 deletions
|
@ -14,6 +14,7 @@ module.exports = function (config) {
|
|||
browsers: ['ChromeCustom'],
|
||||
files: [
|
||||
'test/unit_frontend/js/bootstrap.js',
|
||||
'test/unit_frontend/es/es-bootstrap.js',
|
||||
// Angular must be loaded before requirejs to set up angular global
|
||||
'public/js/libs/angular-1.6.4.min.js',
|
||||
'public/js/libs/angular-mocks.js',
|
||||
|
|
19
services/web/test/unit_frontend/es/es-bootstrap.js
Normal file
19
services/web/test/unit_frontend/es/es-bootstrap.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* global chai */
|
||||
|
||||
/**
|
||||
* Add chai assertion for comparing CodeMirror Pos objects.
|
||||
* A deep comparison will fail because CodeMirror inserts additional properties
|
||||
* that we want to ignore.
|
||||
*/
|
||||
chai.Assertion.addMethod('equalPos', function (expectedPos) {
|
||||
const { line: actualLine, ch: actualCh } = this._obj
|
||||
const { line: expectedLine, ch: expectedCh } = expectedPos
|
||||
|
||||
this.assert(
|
||||
actualLine === expectedLine && actualCh === expectedCh,
|
||||
`expected #{exp} to equal #{act}`,
|
||||
`expected #{exp} to not equal #{act}`,
|
||||
`Pos({ line: ${expectedLine}, ch: ${expectedCh} })`,
|
||||
`Pos({ line: ${actualLine}, ch: ${actualCh} })`
|
||||
)
|
||||
})
|
Loading…
Reference in a new issue