All files / src/components/match ScoutingFormStrip.vue

100% Statements 30/30
77.77% Branches 7/9
100% Functions 1/1
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 521x 1x     1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x       1x 1x 1x 1x       1x         1x   1x         1x   1x 1x   1x 20x 20x 4x 4x    
<template>
  <!--
    A team's "Last N" strip (SB-1869): oldest to newest, latest on the right,
    like the league table's Form column. The API sends `form` newest first.
  -->
  <div
    v-if="results.length"
    class="flex gap-1"
    :class="align === 'end' ? 'justify-end' : ''"
    role="img"
    :aria-label="label"
    data-testid="scouting-form"
  >
    <span
      v-for="f in results"
      :key="f.match_id"
      :title="formChipTitle(f)"
      :class="[
        'w-6 h-6 rounded text-xs font-bold flex items-center justify-center',
        resultClass(f.result),
      ]"
      data-testid="scouting-form-result"
      >{{ f.result }}</span
    >
  </div>
</template>
 
<script setup>
import { computed } from 'vue';
import {
  formChipTitle,
  formStripLabel,
  oldestFirst,
} from '../../utils/formStrip';
 
const props = defineProps({
  /** The dossier's `form`, newest first, as the API sends it. */
  form: { type: Array, default: () => [] },
  /** 'start' or 'end': which edge the chips sit on. */
  align: { type: String, default: 'start' },
});
 
const results = computed(() => oldestFirst(props.form));
const label = computed(() => formStripLabel(results.value.map(f => f.result)));
 
const resultClass = r => {
  if (r === 'W') return 'bg-green-700 text-white';
  if (r === 'L') return 'bg-red-600 text-white';
  return 'bg-surface-alt text-fg border border-line';
};
</script>