import {describe, it} from 'vitest'
import {parseLearningSequences} from '../circle';
import type {WagtailCircle} from '@/types';

describe('circleService.parseLearningSequences', () => {
  it('can parse learning sequences from api response', () => {
    const input = {
      "id": 10,
      "title": "Analyse",
      "slug": "analyse",
      "type": "learnpath.Circle",
      "translation_key": "c9832aaf-02b2-47af-baeb-bde60d8ec1f5",
      "children": [
        {
          "id": 18,
          "title": "Anwenden",
          "slug": "anwenden",
          "type": "learnpath.LearningSequence",
          "translation_key": "2e4c431a-9602-4398-ad18-20dd4bb189fa",
          "icon": "it-icon-ls-apply"
        },
        {
          "id": 19,
          "title": "Prämien einsparen",
          "slug": "pramien-einsparen",
          "type": "learnpath.LearningUnit",
          "translation_key": "75c1f31a-ae25-4d9c-9206-a4e7fdae8c13",
          "questions": []
        },
        {
          "id": 20,
          "title": "Versicherungsbedarf für Familien",
          "slug": "versicherungsbedarf-für-familien",
          "type": "learnpath.LearningContent",
          "translation_key": "2a422da3-a3ad-468a-831e-9141c122ffef",
          "minutes": 60,
          "contents": [
            {
              "type": "exercise",
              "value": {
                "description": "Beispiel Aufgabe"
              },
              "id": "ee0bcef7-702b-42f3-a891-88a0332fce6f"
            }
          ]
        },
        {
          "id": 21,
          "title": "Alles klar?",
          "slug": "alles-klar",
          "type": "learnpath.LearningContent",
          "translation_key": "7dc9d96d-07f9-4b9f-bec1-43ba67cf9010",
          "minutes": 60,
          "contents": [
            {
              "type": "exercise",
              "value": {
                "description": "Beispiel Aufgabe"
              },
              "id": "a556ebb2-f902-4d78-9b76-38b7933118b8"
            }
          ]
        },
        {
          "id": 22,
          "title": "Sich selbständig machen",
          "slug": "sich-selbstandig-machen",
          "type": "learnpath.LearningUnit",
          "translation_key": "c40d5266-3c94-4b9b-8469-9ac6b32a6231",
          "questions": []
        },
        {
          "id": 23,
          "title": "GmbH oder AG",
          "slug": "gmbh-oder-ag",
          "type": "learnpath.LearningContent",
          "translation_key": "59331843-9f52-4b41-9cd1-2293a8d90064",
          "minutes": 120,
          "contents": [
            {
              "type": "video",
              "value": {
                "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam",
                "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
              },
              "id": "a4974834-f404-4fb8-af94-a24c6db56bb8"
            }
          ]
        },
        {
          "id": 24,
          "title": "Tiertherapie Patrizia Feller",
          "slug": "tiertherapie-patrizia-feller",
          "type": "learnpath.LearningContent",
          "translation_key": "13f6d661-1d10-4b59-b8e5-01fcec47a38f",
          "minutes": 120,
          "contents": [
            {
              "type": "exercise",
              "value": {
                "description": "Beispiel Aufgabe"
              },
              "id": "5947c947-8656-44b5-826c-1787057c2df2"
            }
          ]
        },
        {
          "id": 25,
          "title": "Auto verkaufen",
          "slug": "auto-verkaufen",
          "type": "learnpath.LearningUnit",
          "translation_key": "3b42e514-0bbe-4c23-9c88-3f5263e47cf9",
          "questions": []
        },
      ],
      "description": "Nach dem Gespräch werten sie die Analyse aus...",
      "job_situations": [],
      "goals": [],
      "experts": []
    } as WagtailCircle;

    const learningSequences = parseLearningSequences(input.children);
    expect(learningSequences.length).toBe(1);
    console.log(learningSequences[0].learningUnits[0].learningContents[0]);

    expect(
      learningSequences[0].learningUnits[1].learningContents[0].previousLearningContent.translation_key
    ).toEqual(learningSequences[0].learningUnits[0].learningContents[1].translation_key);
  })
})
