Skip to content

Commit 961eb70

Browse files
committed
Adding specs for missing util functions
1 parent d054634 commit 961eb70

File tree

1 file changed

+185
-0
lines changed

1 file changed

+185
-0
lines changed

test/unit/bin/helpers/utils.js

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,189 @@ describe("utils", () => {
236236
sinon.assert.calledOnce(sendUsageReportStub);
237237
});
238238
});
239+
240+
describe("setBuildName", () => {
241+
it("sets the build name from args list", () => {
242+
let argBuildName = "argBuildName";
243+
let bsConfig = {
244+
run_settings: {
245+
build_name: "build_name"
246+
}
247+
};
248+
let args = {
249+
'build-name': argBuildName
250+
};
251+
252+
utils.setBuildName(bsConfig, args);
253+
expect(bsConfig.run_settings.build_name).to.be.eq(argBuildName);
254+
});
255+
});
256+
257+
describe("setUsername", () => {
258+
it("sets the username from args list", () => {
259+
let argUserName = "argUserName";
260+
let bsConfig = {
261+
auth: {
262+
username: "username"
263+
}
264+
};
265+
let args = {
266+
username: argUserName
267+
};
268+
269+
utils.setUsername(bsConfig, args);
270+
expect(bsConfig.auth.username).to.be.eq(argUserName);
271+
});
272+
});
273+
274+
describe("setAccessKey", () => {
275+
it("sets the access key from args list", () => {
276+
let argAccessKey = "argAccessKey";
277+
let bsConfig = {
278+
auth: {
279+
access_key: "access_key"
280+
}
281+
};
282+
let args = {
283+
key: argAccessKey
284+
};
285+
286+
utils.setAccessKey(bsConfig, args);
287+
expect(bsConfig.auth.access_key).to.be.eq(argAccessKey);
288+
});
289+
});
290+
291+
describe("setUserSpecs", () => {
292+
it("sets the specs from args list without space after comma with single space in given list", () => {
293+
let argsSpecs = "spec3, spec4";
294+
let bsConfig = {
295+
run_settings: {
296+
specs: "spec1, spec2"
297+
}
298+
};
299+
let args = {
300+
specs: argsSpecs
301+
};
302+
303+
utils.setUserSpecs(bsConfig, args);
304+
expect(bsConfig.run_settings.specs).to.be.eq('spec3,spec4');
305+
});
306+
307+
it("sets the specs from args list without space after comma with spaces in given list", () => {
308+
let argsSpecs = "spec3 , spec4";
309+
let bsConfig = {
310+
run_settings: {
311+
specs: "spec1, spec2"
312+
}
313+
};
314+
let args = {
315+
specs: argsSpecs
316+
};
317+
318+
utils.setUserSpecs(bsConfig, args);
319+
expect(bsConfig.run_settings.specs).to.be.eq('spec3,spec4');
320+
});
321+
322+
it("sets the specs list from specs key without space after comma with once space after comma in given list", () => {
323+
let bsConfig = {
324+
run_settings: {
325+
specs: "spec1, spec2"
326+
}
327+
};
328+
let args = {
329+
specs: null
330+
};
331+
332+
utils.setUserSpecs(bsConfig, args);
333+
expect(bsConfig.run_settings.specs).to.be.eq('spec1,spec2');
334+
});
335+
336+
it("sets the specs list from specs key without space after comma with extra space in given list", () => {
337+
let bsConfig = {
338+
run_settings: {
339+
specs: "spec1 , spec2"
340+
}
341+
};
342+
let args = {
343+
specs: null
344+
};
345+
346+
utils.setUserSpecs(bsConfig, args);
347+
expect(bsConfig.run_settings.specs).to.be.eq('spec1,spec2');
348+
});
349+
350+
it("sets the specs list from specs key array without space with comma", () => {
351+
let bsConfig = {
352+
run_settings: {
353+
specs: ["spec1", "spec2"]
354+
}
355+
};
356+
let args = {
357+
specs: null
358+
};
359+
360+
utils.setUserSpecs(bsConfig, args);
361+
expect(bsConfig.run_settings.specs).to.be.eq('spec1,spec2');
362+
});
363+
364+
it("does not set the specs list if no specs key specified", () => {
365+
let bsConfig = {
366+
run_settings: {
367+
}
368+
};
369+
let args = {
370+
specs: null
371+
};
372+
373+
utils.setUserSpecs(bsConfig, args);
374+
expect(bsConfig.run_settings.specs).to.be.eq(null);
375+
});
376+
});
377+
378+
describe("setTestEnvs", () => {
379+
it("sets env only from args", () => {
380+
let argsEnv = "env3=value3, env4=value4";
381+
let bsConfig = {
382+
run_settings: {
383+
env: "env1=value1, env2=value2"
384+
}
385+
};
386+
let args = {
387+
env: argsEnv
388+
};
389+
390+
utils.setTestEnvs(bsConfig, args);
391+
expect(bsConfig.run_settings.env).to.be.eq('env3=value3,env4=value4');
392+
});
393+
394+
it("sets env from args without spaces in it", () => {
395+
let argsEnv = "env3=value3 , env4=value4";
396+
let bsConfig = {
397+
run_settings: {
398+
env: "env1=value1 , env2=value2"
399+
}
400+
};
401+
let args = {
402+
env: argsEnv
403+
};
404+
405+
utils.setTestEnvs(bsConfig, args);
406+
expect(bsConfig.run_settings.env).to.be.eq('env3=value3,env4=value4');
407+
});
408+
409+
it("does not set env if not specified in args", () => {
410+
let argsEnv = "env3=value3 , env4=value4";
411+
let bsConfig = {
412+
run_settings: {
413+
env: "env1=value1 , env2=value2"
414+
}
415+
};
416+
let args = {
417+
env: null
418+
};
419+
420+
utils.setTestEnvs(bsConfig, args);
421+
expect(bsConfig.run_settings.env).to.be.eq(null);
422+
});
423+
});
239424
});

0 commit comments

Comments
 (0)