import { expect, test } from 'vitest'
import { TokenDictionary } from '../src/dictionary'

test('resolve aliases', () => {
  const dictionary = new TokenDictionary({
    tokens: {
      colors: {
        pink: { value: '#ff00ff' },
        border: { value: 'token(colors.pink)' },
        disabled: { value: 'token(colors.border)' },
      },
    },
  })

  dictionary.registerTokens()
  dictionary.build()

  expect(dictionary.allTokens).toMatchInlineSnapshot(`
    [
      Token {
        "deprecated": undefined,
        "description": undefined,
        "extensions": {
          "category": "colors",
          "condition": "base",
          "prop": "pink",
        },
        "name": "colors.pink",
        "originalValue": "#ff00ff",
        "path": [
          "colors",
          "pink",
        ],
        "type": "color",
        "value": "#ff00ff",
      },
      Token {
        "deprecated": undefined,
        "description": undefined,
        "extensions": {
          "category": "colors",
          "condition": "base",
          "prop": "border",
        },
        "name": "colors.border",
        "originalValue": "token(colors.pink)",
        "path": [
          "colors",
          "border",
        ],
        "type": "color",
        "value": "#ff00ff",
      },
      Token {
        "deprecated": undefined,
        "description": undefined,
        "extensions": {
          "category": "colors",
          "condition": "base",
          "prop": "disabled",
        },
        "name": "colors.disabled",
        "originalValue": "token(colors.border)",
        "path": [
          "colors",
          "disabled",
        ],
        "type": "color",
        "value": "#ff00ff",
      },
    ]
  `)
})
