Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit c5dcf85

Browse files
authored
test: add context example (#181)
* chore: formatting * test: add context usage example test
1 parent d6f56ba commit c5dcf85

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Workflow.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ describe('Instantiate a Workflow with sequential jobs', () => {
241241
expect(generatedWorkflow).toEqual(expected);
242242
});
243243
});
244+
244245
describe('Instantiate a Workflow with 2 jobs', () => {
245246
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
246247
const helloWorld = new CircleCI.commands.Run({ command: 'echo hello world' });
@@ -311,3 +312,26 @@ describe('Add pre/post steps to workflow', () => {
311312
expect(generatedWorkflow).toEqual(expected);
312313
});
313314
});
315+
316+
describe('Instantiate a deployment job with a context', () => {
317+
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
318+
const deployCommand = new CircleCI.commands.Run({
319+
command: 'npm run deploy',
320+
});
321+
const deployJob = new CircleCI.Job('deploy-job', docker, [deployCommand]);
322+
const deployWorkflow = new CircleCI.Workflow('deploy');
323+
deployWorkflow.addJob(deployJob, {
324+
context: ['deployment-context'],
325+
});
326+
it('Should match the expected output', () => {
327+
const expectedYaml = `deploy:
328+
jobs:
329+
- deploy-job:
330+
context:
331+
- deployment-context
332+
`;
333+
const expected = YAML.parse(expectedYaml);
334+
const generatedWorkflow = deployWorkflow.generate(true);
335+
expect(generatedWorkflow).toEqual(expected);
336+
});
337+
});

0 commit comments

Comments
 (0)