You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
974 B
29 lines
974 B
import { TEST_ANALYTIC_UNIT_ID } from './utils_for_tests/analytic_units'; |
|
import { buildSegments, clearSegmentsDB, convertSegmentsToTimeRanges } from './utils_for_tests/segments'; |
|
|
|
import * as Segment from '../src/models/segment_model'; |
|
|
|
import * as _ from 'lodash'; |
|
|
|
const INITIAL_SEGMENTS = buildSegments([[0, 1], [2, 3], [4, 5]]); |
|
|
|
beforeEach(async () => { |
|
await Segment.mergeAndInsertSegments(INITIAL_SEGMENTS); |
|
}); |
|
|
|
afterEach(async () => { |
|
await clearSegmentsDB(); |
|
}); |
|
|
|
describe('mergeAndInsertSegments', function() { |
|
it('Should be merged before insertion', async function() { |
|
const segmentsToInsert = buildSegments([[1, 2]]); |
|
await Segment.mergeAndInsertSegments(segmentsToInsert); |
|
|
|
let actualSegments = await Segment.findMany(TEST_ANALYTIC_UNIT_ID, {}); |
|
actualSegments.forEach(s => { s.id = undefined }); |
|
actualSegments = _.sortBy(actualSegments, s => s.from); |
|
expect(actualSegments).toEqual(buildSegments([[0, 3], [4, 5]])); |
|
}); |
|
}); |
|
|
|
|