jstools-utils
Version:
utils jstool example
99 lines (66 loc) • 2.19 kB
JavaScript
describe('jstool-utils: utils.js', function () {
it('_.isFunction', function () {
expect( _.isFunction(function () {}) ).toBe(true);
});
it('_.isObject', function () {
expect( _.isObject({}) ).toBe(true);
});
it('_.isString', function () {
expect( _.isString('this is a string') ).toBe(true);
});
it('_.isNumber', function () {
expect( _.isNumber(45) ).toBe(true);
});
it('_.isArray', function () {
expect( _.isArray([]) ).toBe(true);
});
it('_.key get', function () {
var o = { foo: 'bar' }
expect( _.key(o, 'foo') ).toBe('bar');
});
it('_.key set', function () {
var o = { foo: 'bar' }
_.key(o, 'foo', 'changed');
expect( o.foo ).toBe('changed');
});
it('_.key set 2nd level', function () {
var o = {}
_.key(o, 'foo.bar', 'foobar');
expect( o.foo.bar ).toBe('foobar');
});
it('_.extend', function () {
var o = { foo: 'bar' };
_.extend(o, { crash: 'test' }, { test: 'dummy' });
expect( JSON.stringify(o) ).toBe('{"foo":"bar","crash":"test","test":"dummy"}');
});
it('_.extend no deep', function () {
var o = { foo: 'bar' };
_.extend(o, { crash: 'test', test: { dummy: 'oO' } }, { test: 'dummy' });
expect( JSON.stringify(o) ).toBe('{"foo":"bar","crash":"test","test":"dummy"}');
});
it('_.merge', function () {
var o = {};
_.merge(o, { crash: 'test', test: { dummy: 'oO' } }, { test: { foo: 'bar' } });
expect( JSON.stringify(o) ).toBe('{"crash":"test","test":{"dummy":"oO","foo":"bar"}}');
});
it('_.merge', function () {
var o = {};
_.merge(o, { crash: 'test', test: { list: [1,2,3] } }, { test: { list: [4,5,6] } });
expect( JSON.stringify(o) ).toBe('{"crash":"test","test":{"list":[1,2,3,4,5,6]}}');
});
it('_.joinPath', function () {
expect( _.joinPath('foo', 'bar') ).toBe('foo/bar');
});
it('_.joinPath (2)', function () {
expect( _.joinPath('foo/', 'bar') ).toBe('foo/bar');
});
it('_.joinPath (3)', function () {
expect( _.joinPath('foo', '/bar') ).toBe('foo/bar');
});
it('_.joinPath (4)', function () {
expect( _.joinPath('foo/', '/bar') ).toBe('foo/bar');
});
it('_.joinPath (5)', function () {
expect( _.joinPath('foobar') ).toBe('foobar');
});
});