<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>yaml-001</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-01-03</t:date>
        <t:author>
          <t:name>Norm Tovey-Walsh</t:name>
        </t:author>
        <t:description xmlns="http://www.w3.org/1999/xhtml">
          <p>Created test.</p>
        </t:description>
      </t:revision>
    </t:revision-history>
  </t:info>
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Tests that YAML can be parsed.</p>
  </t:description>
  <t:pipeline>
    <p:declare-step version="3.0"
                    xmlns:err="http://www.w3.org/ns/xproc-error"
                    xmlns:cx="http://xmlcalabash.com/ns/extensions"
                    xmlns:p="http://www.w3.org/ns/xproc">
      <p:output port="result"/>

      <p:identity>
        <p:with-input>
          <p:inline content-type="application/yaml">
name: build-pr
on:
  pull_request_target:
    types: [assigned, opened, edited, synchronize, reopened]
    branches:
      - main
          </p:inline>
        </p:with-input>
      </p:identity>
      <p:cast-content-type content-type="application/xml"/>
    </p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="fn:map">The result isn’t a map.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/fn:map">
          <s:assert test="fn:string[@key='name'] = 'build-pr'">The name is wrong.</s:assert>
          <s:assert test="fn:map[@key='on']">There’s no ‘on’ map.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/fn:map/fn:map[@key='on']">
          <s:assert test="fn:map[@key='pull_request_target']">There’s no pull request target map.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/fn:map/fn:map[@key='on']/fn:map[@key='pull_request_target']">
          <s:assert test="fn:array[@key='types']">There’s no types array.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
