Files
iD/test/spec/util.js
Tom MacWright 7e9a427a2b Test getPrototype, use American spellings, fix test formatting.
* Stub Lasso test
* Add cmd test
2013-03-05 17:59:50 -05:00

32 lines
1.2 KiB
JavaScript

describe('iD.Util', function() {
it('#trueObj', function() {
expect(iD.util.trueObj(['a', 'b', 'c'])).to.eql({ a: true, b: true, c: true });
expect(iD.util.trueObj([])).to.eql({});
});
it('#tagText', function() {
expect(iD.util.tagText({})).to.eql('');
expect(iD.util.tagText({tags:{foo:'bar'}})).to.eql('foo=bar');
expect(iD.util.tagText({tags:{foo:'bar',two:'three'}})).to.eql('foo=bar, two=three');
});
it('#stringQs', function() {
expect(iD.util.stringQs('foo=bar')).to.eql({foo: 'bar'});
expect(iD.util.stringQs('foo=bar&one=2')).to.eql({foo: 'bar', one: '2' });
expect(iD.util.stringQs('')).to.eql({});
});
it('#qsString', function() {
expect(iD.util.qsString({ foo: 'bar' })).to.eql('foo=bar');
expect(iD.util.qsString({ foo: 'bar', one: 2 })).to.eql('foo=bar&one=2');
expect(iD.util.qsString({})).to.eql('');
});
it('#getPrototypeOf', function() {
var a = function() {};
a.prototype = { foo: 'foo' };
expect(iD.util.getPrototypeOf({})).to.eql({});
expect(iD.util.getPrototypeOf(new a())).to.eql({ foo: 'foo' });
});
});