name: Tests JavaScript

on:
    pull_request:
        branches:
            - main

jobs:
    test:
        runs-on: ubuntu-latest
        defaults:
            run:
                working-directory: ./assets
        strategy:
            matrix:
                node-version: ["20.x", "22.x"]

        steps:
            - uses: actions/checkout@v4
              with:
                  ref: ${{ github.event.pull_request.head.sha || github.ref }}

            - name: Setup Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
                  cache: 'yarn'
                  cache-dependency-path: './assets/yarn.lock'

            - name: Install dependencies
              run: yarn install --frozen-lockfile

            - name: Run TypeScript tests
              run: yarn test
