name: CRON tests

on:
  push:
    branches:
      - cron
  schedule:
    - cron:  '0 3 * * *'

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
    - uses: actions/checkout@v1

    - name: Install npm dependencies
      run: yarn install

    - name: Build
      run: yarn build

    - name: Test in node
      run: node test/require-in-node

    - name: Test in jest
      run: |
        yarn add --dev jest
        ./node_modules/.bin/jest --ci test/jest/jest.test.js

    - name: Test dist/*.min.js
      run: yarn test --minified

    - name: Run cross-platform tests with SauceLabs
      env:
        SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
        SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
      run: |
        yarn test --sauce
        yarn test --sauce --minified

    - name: Test jsdelivr
      run: curl --location 'https://cdn.jsdelivr.net/npm/sweetalert2' 2>&1 | grep --quiet 'this.Swal'

    - name: Test unpkg
      run: curl --location 'https://unpkg.com/sweetalert2' 2>&1 | grep --quiet 'this.Swal'
