summaryrefslogtreecommitdiff
path: root/spec/frontend/pipeline_wizard/validators_spec.js
blob: 1276c642f3071375143bd0bffef3f6d21bb274f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Document, parseDocument } from 'yaml';
import { isValidStepSeq } from '~/pipeline_wizard/validators';
import { steps as stepsYaml } from './mock/yaml';

describe('prop validation', () => {
  const steps = parseDocument(stepsYaml).toJS();
  const getAsYamlNode = (value) => new Document(value).contents;

  it('allows passing yaml nodes to the steps prop', () => {
    const validSteps = getAsYamlNode(steps);
    expect(isValidStepSeq(validSteps)).toBe(true);
  });

  it.each`
    scenario                     | stepsValue
    ${'not a seq'}               | ${{ foo: 'bar' }}
    ${'a step missing an input'} | ${[{ template: 'baz: boo' }]}
    ${'an empty seq'}            | ${[]}
  `('throws an error when passing $scenario to the steps prop', ({ stepsValue }) => {
    expect(isValidStepSeq(stepsValue)).toBe(false);
  });
});