utils.js 944 B

12345678910111213141516171819202122232425262728
  1. describe('utils', function () {
  2. var utils = require('../lib/utils');
  3. describe('#extend', function () {
  4. var extend = utils.extend;
  5. it('extends an object with the attributes of another object', function () {
  6. var obj = { a: 1, b: 2 };
  7. extend(obj, { c: 3 });
  8. obj.should.deep.equal({ a: 1, b: 2, c: 3 });
  9. });
  10. it('extends an object with the attributes of multiple other objects', function () {
  11. var obj = { a: 1 };
  12. extend(obj, { b: 2 }, { c: 3 });
  13. obj.should.deep.equal({ a: 1, b: 2, c: 3 });
  14. });
  15. });
  16. describe('#replace', function () {
  17. var replace = utils.replace;
  18. it('replaces the placeholders in a string', function () {
  19. var str = 'http://:username::password@saucelabs.com/rest/v1/:username/tunnels/:id';
  20. str = replace(str, { username: 'foo', password: 'bar' });
  21. str.should.equal('http://foo:bar@saucelabs.com/rest/v1/foo/tunnels/:id');
  22. });
  23. });
  24. });