2022-11-26 08:34:23 +11:00
|
|
|
import { isOverlapping } from './utils'
|
|
|
|
import { Range } from '../useStore'
|
2022-11-26 05:13:07 +11:00
|
|
|
|
2022-11-26 08:34:23 +11:00
|
|
|
describe('testing isOverlapping', () => {
|
|
|
|
testBothOrders([0, 5], [3, 10])
|
|
|
|
testBothOrders([0, 5], [3, 4])
|
|
|
|
testBothOrders([0, 5], [5, 10])
|
|
|
|
testBothOrders([0, 5], [6, 10], false)
|
|
|
|
testBothOrders([0, 5], [-1, 1])
|
|
|
|
testBothOrders([0, 5], [-1, 0])
|
|
|
|
testBothOrders([0, 5], [-2, -1], false)
|
|
|
|
})
|
2022-11-26 05:13:07 +11:00
|
|
|
|
|
|
|
function testBothOrders(a: Range, b: Range, result = true) {
|
|
|
|
it(`test is overlapping ${a} ${b}`, () => {
|
2022-11-26 08:34:23 +11:00
|
|
|
expect(isOverlapping(a, b)).toBe(result)
|
|
|
|
expect(isOverlapping(b, a)).toBe(result)
|
|
|
|
})
|
2022-11-26 05:13:07 +11:00
|
|
|
}
|