import assert from 'assert'
import {ugf} from '../src/modules/fileformats/index.js'

describe('ugf', () => {
  describe('parse', () => {
    it('should parse simple files', () => {
      let tree = ugf.parseFile(`${__dirname}/ugf/amateur.ugf`)[0]

      assert.deepEqual(tree.root.data, {
        CA: ['UTF-8'],
        CP: ['PANDANET INC.'],
        FF: ['4'],
        GM: ['1'],
        SZ: ['19'],
        KM: ['-5.50'],
        PW: ['YINNI'],
        WR: ['8d'],
        PB: ['kaziwami'],
        BR: ['7d'],
        DT: ['2019-03-08'],
        RE: ['B+7.50']
      })

      assert.deepEqual(
        [...tree.getSequence(tree.root.id)].map(node => node.data).slice(1, 5),
        [{B: ['qd']}, {W: ['dd']}, {B: ['pq']}, {W: ['dq']}]
      )
    })
  })
})

@@ -746,16 +746,291 @@
 )%0A    %7D)
+%0A%0A    it('should parse reviews with comments and variations', () =%3E %7B%0A      let tree = ugf.parseFile(%60$%7B__dirname%7D/ugf/review.ugi%60)%5B0%5D%0A%0A      assert.equal(%0A        tree.root.data.C,%0A        %60apetresc 2k?: Let's begin and enjoy a great game.%0Aken03110 2k : Hi!%0A%60%0A      )%0A    %7D)
 %0A  %7D)%0A%7D)

Add test for review comments