'use strict'

const { it } = require('node:test')

const assert = require('assert')
const yaml = require('js-yaml')

const tags = [{
  tag: 'Include',
  type: 'scalar'
}, {
  tag: 'Include',
  type: 'mapping'
}].map(function (fn) {
  return new yaml.Type('!' + fn.tag, {
    kind: fn.type,
    resolve: function () {
      return true
    },
    construct: function (obj) {
      return obj
    }
  })
})

const schema = yaml.DEFAULT_SCHEMA.extend(tags)

it('Process tag with kind: scalar', function () {
  assert.deepStrictEqual(yaml.load('!Include foobar', {
    schema: schema
  }), 'foobar')
})

it('Process tag with kind: mapping', function () {
  assert.deepStrictEqual(yaml.load('!Include\n  location: foobar', {
    schema: schema
  }), { location: 'foobar' })
})
