Skip to content

Commit

Permalink
test: add context example (#181)
Browse files Browse the repository at this point in the history
* chore: formatting

* test: add context usage example test
  • Loading branch information
KyleTryon authored May 22, 2023
1 parent d6f56ba commit c5dcf85
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ describe('Instantiate a Workflow with sequential jobs', () => {
expect(generatedWorkflow).toEqual(expected);
});
});

describe('Instantiate a Workflow with 2 jobs', () => {
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
const helloWorld = new CircleCI.commands.Run({ command: 'echo hello world' });
Expand Down Expand Up @@ -311,3 +312,26 @@ describe('Add pre/post steps to workflow', () => {
expect(generatedWorkflow).toEqual(expected);
});
});

describe('Instantiate a deployment job with a context', () => {
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
const deployCommand = new CircleCI.commands.Run({
command: 'npm run deploy',
});
const deployJob = new CircleCI.Job('deploy-job', docker, [deployCommand]);
const deployWorkflow = new CircleCI.Workflow('deploy');
deployWorkflow.addJob(deployJob, {
context: ['deployment-context'],
});
it('Should match the expected output', () => {
const expectedYaml = `deploy:
jobs:
- deploy-job:
context:
- deployment-context
`;
const expected = YAML.parse(expectedYaml);
const generatedWorkflow = deployWorkflow.generate(true);
expect(generatedWorkflow).toEqual(expected);
});
});

0 comments on commit c5dcf85

Please sign in to comment.