import { grp, grp2024, grp2025 } from '../exports/index'
import { testingSets } from './stub/grp-input.stub'

describe('grouping', () => {
  describe('2025 version with multiple rumObjects', () => {
    for (let i = 0; i < testingSets.length; i++) {
      const testSet = testingSets[i]

      it(`2025 grouping should work for test set ${i + 1}`, () => {
        const result2025 = grp2025({
          rumObjects: testSet.rumObjects,
          typeEtab: testSet.typeEtab
        })

        expect(result2025.grp_res.ghm).toBe(testSet.expectedGHM)
      })
    }
  })

  describe('2024 version with multiple rumObjects', () => {
    for (let i = 0; i < testingSets.length; i++) {
      const testSet = testingSets[i]

      it(`2024 grouping should work for test set ${i + 1}`, () => {
        const result2024 = grp2024({
          rumObjects: testSet.rumObjects,
          typeEtab: testSet.typeEtab
        })

        expect(result2024.grp_res.ghm).toBe(testSet.expectedGHM)
        expect(result2024.grp_res.cmd).toBe(testSet.expectedCMD)
        expect(result2024.returnError).toEqual(testSet.returnError)
      })
    }
  })

  describe('grp version with multiple rumObjects', () => {
    for (let i = 0; i < testingSets.length; i++) {
      const testSet = testingSets[i]

      it(`grp grouping should work for test set ${i + 1}`, () => {
        const result = grp({
          rumObjects: testSet.rumObjects,
          typeEtab: testSet.typeEtab
        })

        expect(result.grp_res.ghm).toBe(testSet.expectedGHM)
        expect(result.grp_res.cmd).toBe(testSet.expectedCMD)
        expect(result.returnError).toEqual(testSet.returnError)
      })
    }
  })
})
