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

Commit 1ad01c8

Browse files
committed
test: add job parameters
1 parent 18baec7 commit 1ad01c8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Job.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ describe('Instantiate Docker Job', () => {
2626
});
2727
});
2828

29+
describe('Instantiate Docker Job with custom properties', () => {
30+
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
31+
const helloWorld = new CircleCI.commands.Run({
32+
command: 'echo hello world',
33+
});
34+
const jobName = 'my-job';
35+
const job = new CircleCI.Job(jobName, docker, [helloWorld], {
36+
parallelism: 3,
37+
circleci_ip_ranges: true,
38+
});
39+
const jobContents = {
40+
docker: [{ image: 'cimg/node:lts' }],
41+
resource_class: 'medium',
42+
parallelism: 3,
43+
circleci_ip_ranges: true,
44+
steps: [{ run: 'echo hello world' }],
45+
};
46+
47+
it('Should match the expected output', () => {
48+
expect(job.generate(true)).toEqual({ [jobName]: jobContents });
49+
});
50+
51+
it('Add job to config and validate', () => {
52+
const myConfig = new CircleCI.Config();
53+
myConfig.addJob(job);
54+
expect(myConfig.jobs.length).toBeGreaterThan(0);
55+
});
56+
});
57+
2958
describe('Instantiate Parameterized Docker Job With Custom Parameters', () => {
3059
const docker = new CircleCI.executors.DockerExecutor('cimg/node:lts');
3160
const helloWorld = new CircleCI.commands.Run({

0 commit comments

Comments
 (0)