Update tests.

This commit is contained in:
Lars Jung 2015-06-14 15:24:05 +02:00
parent 18a62ca831
commit 787eae7a80
22 changed files with 113 additions and 161 deletions

View file

@ -9,8 +9,8 @@ describe('view', function () {
this.storeKey = '_h5ai';
this.xConfig = {
setup: {
PUBLIC_HREF: util.uniqPath('-PUBLIC/'),
ROOT_HREF: util.uniqPath('-ROOT/')
PUBLIC_HREF: uniq.path('-PUBLIC/'),
ROOT_HREF: uniq.path('-ROOT/')
}
};
});

View file

@ -38,44 +38,10 @@ describe('premisses', function () {
assert.strictEqual(util, window.util);
});
it('util.uniqId() works', function () {
it('uniq is global object', function () {
assert.isFunction(util.uniqId);
var uid1 = parseInt(util.uniqId().replace(/\D/g, ''), 10);
assert.isTrue(util.isUniqId(util.uniqId()));
assert.notEqual(util.uniqId(), util.uniqId());
assert.notDeepEqual(util.uniqId(), util.uniqId());
assert.notStrictEqual(util.uniqId(), util.uniqId());
var uid2 = parseInt(util.uniqId().replace(/\D/g, ''), 10);
assert.strictEqual(uid2, uid1 + 8);
});
it('util.uniqObj() works', function () {
assert.isFunction(util.uniqId);
assert.lengthOfKeys(util.uniqObj(), 1);
assert.isTrue(util.isUniqId(util.uniqObj().uniqId));
assert.notEqual(util.uniqObj(), util.uniqObj());
assert.notDeepEqual(util.uniqObj(), util.uniqObj());
assert.notStrictEqual(util.uniqObj(), util.uniqObj());
assert.notEqual(util.uniqObj().uniqId, util.uniqObj().uniqId);
assert.notDeepEqual(util.uniqObj().uniqId, util.uniqObj().uniqId);
assert.notStrictEqual(util.uniqObj().uniqId, util.uniqObj().uniqId);
});
it('util.uniqPath() works', function () {
assert.isFunction(util.uniqPath);
assert.notEqual(util.uniqPath(), util.uniqPath());
assert.notDeepEqual(util.uniqPath(), util.uniqPath());
assert.notStrictEqual(util.uniqPath(), util.uniqPath());
assert.strictEqual(util.uniqPath('abc').substr(-3), 'abc');
assert.strictEqual(util.uniqPath('xyz/').substr(-4), 'xyz/');
assert.isPlainObject(util);
assert.strictEqual(util, window.util);
});
it('assert.isPlainObject() works', function () {

View file

@ -10,7 +10,7 @@ describe('module \'' + ID + '\'', function () {
this.definition = modulejs._private.definitions[ID];
this.xConfig = util.uniqObj();
this.xConfig = uniq.obj();
this.xDefine = sinon.stub(modulejs, 'define');
this.xRequire = sinon.stub(modulejs, 'require');
this.xServer = {

View file

@ -53,7 +53,7 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
assert.isPlainObject(instance);
assert.lengthOfKeys(instance, 1);
assert.isTrue(util.isUniqId(instance.uniqId));
assert.isTrue(uniq.isId(instance._uniq_id));
});
});
});

View file

@ -10,7 +10,7 @@ describe('module \'' + ID + '\'', function () {
this.definition = modulejs._private.definitions[ID];
this.xConfig = {langs: util.uniqObj()};
this.xConfig = {langs: uniq.obj()};
this.applyFn = function () {
return this.definition.fn(_, this.xConfig);

View file

@ -242,7 +242,7 @@ describe('module \'' + ID + '\'', function () {
var $el = $('<a/>');
var item = {
absHref: util.uniqId(),
absHref: uniq.id(),
isManaged: false,
isFolder: sinon.stub().returns(false)
};
@ -259,7 +259,7 @@ describe('module \'' + ID + '\'', function () {
var $el = $('<a/>');
var item = {
absHref: util.uniqId(),
absHref: uniq.id(),
isManaged: false,
isFolder: sinon.stub().returns(true)
};
@ -276,7 +276,7 @@ describe('module \'' + ID + '\'', function () {
var $el = $('<a/>');
var item = {
absHref: util.uniqId(),
absHref: uniq.id(),
isManaged: true,
isFolder: sinon.stub().returns(true)
};
@ -293,7 +293,7 @@ describe('module \'' + ID + '\'', function () {
var $el = $('<a/>');
var item = {
absHref: util.uniqId(),
absHref: uniq.id(),
isManaged: true,
isFolder: sinon.stub().returns(true)
};

View file

@ -16,7 +16,7 @@ describe('module \'' + ID + '\'', function () {
b: 'myTheme/b.jpg'
}
};
this.xSettings = {publicHref: util.uniqPath('/publicHref/')};
this.xSettings = {publicHref: uniq.path('/publicHref/')};
this.applyFn = function () {
return this.definition.fn(_, this.xConfig, this.xSettings);
@ -62,7 +62,7 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
assert.isPlainObject(instance);
assert.lengthOf(_.keys(instance), 2);
assert.lengthOfKeys(instance, 2);
});
});

View file

@ -81,7 +81,7 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
assert.isPlainObject(instance);
assert.lengthOf(_.keys(instance), 2);
assert.lengthOfKeys(instance, 2);
});
});
@ -97,8 +97,8 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
var xData = util.uniqObj();
var xResult = util.uniqObj();
var xData = uniq.obj();
var xResult = uniq.obj();
var spy = sinon.spy();
var res = instance.request(xData, spy);
@ -124,7 +124,7 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
var xData = util.uniqObj();
var xData = uniq.obj();
var spy = sinon.spy();
var res = instance.request(xData, spy);
@ -160,8 +160,8 @@ describe('module \'' + ID + '\'', function () {
var instance = this.applyFn();
var xData = {
a: util.uniqId(),
b: util.uniqId()
a: uniq.id(),
b: uniq.id()
};
var res = instance.formRequest(xData);

View file

@ -12,13 +12,13 @@ describe('module \'' + ID + '\'', function () {
this.xConfig = {
options: {
someOptions: util.uniqObj(),
otherOptions: util.uniqObj(),
more: util.uniqObj()
someOptions: uniq.obj(),
otherOptions: uniq.obj(),
more: uniq.obj()
},
setup: {
PUBLIC_HREF: util.uniqId(),
ROOT_HREF: util.uniqId()
PUBLIC_HREF: uniq.id(),
ROOT_HREF: uniq.id()
}
};
this.applyFn = function () {

View file

@ -12,7 +12,7 @@ describe('module \'' + ID + '\'', function () {
this.xConfig = {
setup: {
VERSION: util.uniqId()
VERSION: uniq.id()
},
options: {}
};
@ -136,7 +136,7 @@ describe('module \'' + ID + '\'', function () {
it('login works', function () {
var pass = util.uniqId();
var pass = uniq.id();
var expectedData = {
action: 'login',
pass: pass

View file

@ -10,19 +10,19 @@ describe('module \'' + ID + '\'', function () {
this.definition = modulejs._private.definitions[ID];
this.xRootName = util.uniqId();
this.xRootName = uniq.id();
this.xTypes = {
getType: sinon.stub().returns(util.uniqId())
getType: sinon.stub().returns(uniq.id())
};
this.xEvent = util.uniqObj();
this.xEvent = uniq.obj();
this.xSettings = {
rootHref: util.uniqPath('/' + this.xRootName + '/')
rootHref: uniq.path('/' + this.xRootName + '/')
};
this.xServer = util.uniqObj();
this.xServer = uniq.obj();
this.xLocation = {
forceEncoding: sinon.stub().returnsArg(0),
getDomain: sinon.stub().returns(util.uniqId()),
getAbsHref: sinon.stub().returns(util.uniqId())
getDomain: sinon.stub().returns(uniq.id()),
getAbsHref: sinon.stub().returns(uniq.id())
};
this.applyFn = function () {

View file

@ -13,8 +13,8 @@ describe('module \'' + ID + '\'', function () {
this.xResource = {
image: sinon.stub().throws('invalid image request')
};
this.xResource.image.withArgs('back').returns(util.uniqPath('-back.png'));
this.xResource.image.withArgs('sidebar').returns(util.uniqPath('-sidebar.png'));
this.xResource.image.withArgs('back').returns(uniq.path('-back.png'));
this.xResource.image.withArgs('sidebar').returns(uniq.path('-sidebar.png'));
this.xStore = {
get: sinon.stub().returns(false),
put: sinon.stub()

View file

@ -16,14 +16,14 @@ describe('module \'' + ID + '\'', function () {
};
this.xFormat = {
setDefaultMetric: sinon.stub(),
formatDate: sinon.stub().returns(util.uniqId()),
formatSize: sinon.stub().returns(util.uniqId())
formatDate: sinon.stub().returns(uniq.id()),
formatSize: sinon.stub().returns(uniq.id())
};
this.xLocation = {
setLink: sinon.stub().returns(util.uniqId())
setLink: sinon.stub().returns(uniq.id())
};
this.xResource = {
icon: sinon.stub().returns(util.uniqId())
icon: sinon.stub().returns(uniq.id())
};
this.xSettings = {view: {
binaryPrefix: false,
@ -253,7 +253,7 @@ describe('module \'' + ID + '\'', function () {
it('sets correct class to #view-hint', function () {
var key = util.uniqId();
var key = uniq.id();
var instance = this.applyFn();
instance.setHint(key);
assert.strictEqual($('#view-hint').attr('class'), 'l10n-' + key);
@ -261,7 +261,7 @@ describe('module \'' + ID + '\'', function () {
it('removes all other classes from #view-hint', function () {
var key = util.uniqId();
var key = uniq.id();
var instance = this.applyFn();
$('#view-hint').addClass('a');
instance.setHint(key);
@ -407,10 +407,10 @@ describe('module \'' + ID + '\'', function () {
// return {
// isFolder: sinon.stub().returns(false),
// label: util.uniqId(),
// label: uniq.id(),
// time: 0,
// size: 0,
// type: util.uniqId(),
// type: uniq.id(),
// isManaged: false,
// icon: null,
// isCurrentParentFolder: sinon.stub().returns(false)

View file

@ -15,7 +15,7 @@ describe('module \'' + ID + '\'', function () {
pub: sinon.stub()
};
this.xResource = {
image: sinon.stub().returns(util.uniqPath('-image.png'))
image: sinon.stub().returns(uniq.path('-image.png'))
};
this.xSettings = {view: {
modeToggle: false