-
-
Save chantalgo/30abc3a04ab87f473b8f10bb9a4bd43a to your computer and use it in GitHub Desktop.
testing on jsbin [mocha template] // source http://jsbin.com/kifeki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[mocha template]"> | |
<meta charset="utf-8"> | |
<title>testing on jsbin</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/mocha/1.18.2/mocha.css"> | |
</head> | |
<body> | |
<div id="mocha"></div> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/mocha/1.18.2/mocha.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/chai/1.9.0/chai.js"></script> | |
<script> | |
mocha.setup('bdd'); | |
var expect = chai.expect; | |
describe('Test current conditional', function() { | |
describe('When value null, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test1(null)).to.have.property('mbid'); | |
}); | |
it('The data to be sent should NOT have property eid', function() { | |
expect(test1(null)).to.not.have.property('ebid'); | |
}); | |
it('Mbid is set to null', function() { | |
expect(test1(null).mbid).to.be.null; | |
}); | |
}); | |
describe('When value is an mbid, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test1(testMbid)).to.have.property('mbid'); | |
}); | |
it('The data sent should NOT have property eid', function() { | |
expect(test1(testMbid)).to.not.have.property('ebid'); | |
}); | |
it('The length of mbid is 36', function() { | |
expect(test1(testMbid).mbid).to.have.lengthOf(36); | |
}); | |
}); | |
describe('When value is an eid, it it set as eid', function() { | |
it('The data to be sent should have property ebid', function() { | |
expect(test1(testEid)).to.have.property('eid'); | |
}); | |
it('The data sent should NOT have property mbid', function() { | |
expect(test1(testEid)).to.not.have.property('mbid'); | |
}); | |
it('The length of mbid is NOT 36', function() { | |
expect(test1(testEid).eid).to.not.have.lengthOf(36); | |
}); | |
}); | |
}); | |
describe('Test new conditional', function() { | |
describe('When value null, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test2(null)).to.have.property('mbid'); | |
}); | |
it('The data to be sent should NOT have property eid', function() { | |
expect(test2(null)).to.not.have.property('ebid'); | |
}); | |
it('Mbid is set to null', function() { | |
expect(test2(null).mbid).to.be.null; | |
}); | |
}); | |
describe('When value is an mbid, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test2(testMbid)).to.have.property('mbid'); | |
}); | |
it('The data sent should NOT have property eid', function() { | |
expect(test2(testMbid)).to.not.have.property('ebid'); | |
}); | |
it('The length of mbid is 36', function() { | |
expect(test2(testMbid).mbid).to.have.lengthOf(36); | |
}); | |
}); | |
describe('When value is an eid, it it set as eid', function() { | |
it('The data to be sent should have property ebid', function() { | |
expect(test2(testEid)).to.have.property('eid'); | |
}); | |
it('The data sent should NOT have property mbid', function() { | |
expect(test2(testEid)).to.not.have.property('mbid'); | |
}); | |
it('The length of mbid is NOT 36', function() { | |
expect(test2(testEid).eid).to.not.have.lengthOf(36); | |
}); | |
}); | |
}); | |
describe('Test conditional to each other', function() { | |
describe('When value null', function() { | |
it('data Object properties match', function() { | |
expect(test1(null).mbid).to.equal(test2(null).mbid); | |
expect(test1(null).eid).to.equal(test2(null).eid); | |
}); | |
}); | |
describe('When value is an mbid', function() { | |
it('data Object properties match', function() { | |
expect(test1(testMbid).mbid).to.equal(test2(testMbid).mbid); | |
expect(test1(testMbid).eid).to.equal(test2(testMbid).eid); }); | |
}); | |
describe('When value is an eid', function() { | |
it('data Object properties match', function() { | |
expect(test1(testEid).mbid).to.equal(test2(testEid).mbid); | |
expect(test1(testEid).eid).to.equal(test2(testEid).eid); }); | |
}); | |
}); | |
mocha.run(); | |
</script> | |
<script id="jsbin-javascript"> | |
var testMbid = "218dfc9e-c77f-4469-80e1-1037b4483601"; | |
var testEid = "01.1472232578.917805cc56ad4efdc3e1b971706df15eab3add359616a00634107760d57d19572b241af6443e55b92760032af0ebaeea017e1d017e3da5fa4ef2455a5d"; | |
function cookieSize(value) { | |
return encodeURIComponent('' + value).length; | |
} | |
function test1(value){ | |
data = {}; | |
cookieSize(value) == 36 ? data.mbid = value : (value == null) ? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function test2(value){ | |
data = {}; | |
((cookieSize(value)==36) || (value == null))? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function resultMbid(){ | |
data = {}; | |
data.mbid = testMbid; | |
return data; | |
} | |
function resultEid(){ | |
data = {}; | |
data.eid = testEid; | |
return data | |
} | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[mocha template]"> | |
<meta charset="utf-8"> | |
<title>testing on jsbin</title> | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/mocha/1.18.2/mocha.css"> | |
</head> | |
<body> | |
<div id="mocha"></div> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/mocha/1.18.2/mocha.js"><\/script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/chai/1.9.0/chai.js"><\/script> | |
<script> | |
mocha.setup('bdd'); | |
var expect = chai.expect; | |
describe('Test current conditional', function() { | |
describe('When value null, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test1(null)).to.have.property('mbid'); | |
}); | |
it('The data to be sent should NOT have property eid', function() { | |
expect(test1(null)).to.not.have.property('ebid'); | |
}); | |
it('Mbid is set to null', function() { | |
expect(test1(null).mbid).to.be.null; | |
}); | |
}); | |
describe('When value is an mbid, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test1(testMbid)).to.have.property('mbid'); | |
}); | |
it('The data sent should NOT have property eid', function() { | |
expect(test1(testMbid)).to.not.have.property('ebid'); | |
}); | |
it('The length of mbid is 36', function() { | |
expect(test1(testMbid).mbid).to.have.lengthOf(36); | |
}); | |
}); | |
describe('When value is an eid, it it set as eid', function() { | |
it('The data to be sent should have property ebid', function() { | |
expect(test1(testEid)).to.have.property('eid'); | |
}); | |
it('The data sent should NOT have property mbid', function() { | |
expect(test1(testEid)).to.not.have.property('mbid'); | |
}); | |
it('The length of mbid is NOT 36', function() { | |
expect(test1(testEid).eid).to.not.have.lengthOf(36); | |
}); | |
}); | |
}); | |
describe('Test new conditional', function() { | |
describe('When value null, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test2(null)).to.have.property('mbid'); | |
}); | |
it('The data to be sent should NOT have property eid', function() { | |
expect(test2(null)).to.not.have.property('ebid'); | |
}); | |
it('Mbid is set to null', function() { | |
expect(test2(null).mbid).to.be.null; | |
}); | |
}); | |
describe('When value is an mbid, it it set as mbid', function() { | |
it('The data to be sent should have property mbid', function() { | |
expect(test2(testMbid)).to.have.property('mbid'); | |
}); | |
it('The data sent should NOT have property eid', function() { | |
expect(test2(testMbid)).to.not.have.property('ebid'); | |
}); | |
it('The length of mbid is 36', function() { | |
expect(test2(testMbid).mbid).to.have.lengthOf(36); | |
}); | |
}); | |
describe('When value is an eid, it it set as eid', function() { | |
it('The data to be sent should have property ebid', function() { | |
expect(test2(testEid)).to.have.property('eid'); | |
}); | |
it('The data sent should NOT have property mbid', function() { | |
expect(test2(testEid)).to.not.have.property('mbid'); | |
}); | |
it('The length of mbid is NOT 36', function() { | |
expect(test2(testEid).eid).to.not.have.lengthOf(36); | |
}); | |
}); | |
}); | |
describe('Test conditional to each other', function() { | |
describe('When value null', function() { | |
it('data Object properties match', function() { | |
expect(test1(null).mbid).to.equal(test2(null).mbid); | |
expect(test1(null).eid).to.equal(test2(null).eid); | |
}); | |
}); | |
describe('When value is an mbid', function() { | |
it('data Object properties match', function() { | |
expect(test1(testMbid).mbid).to.equal(test2(testMbid).mbid); | |
expect(test1(testMbid).eid).to.equal(test2(testMbid).eid); }); | |
}); | |
describe('When value is an eid', function() { | |
it('data Object properties match', function() { | |
expect(test1(testEid).mbid).to.equal(test2(testEid).mbid); | |
expect(test1(testEid).eid).to.equal(test2(testEid).eid); }); | |
}); | |
}); | |
mocha.run(); | |
<\/script> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">var testMbid = "218dfc9e-c77f-4469-80e1-1037b4483601"; | |
var testEid = "01.1472232578.917805cc56ad4efdc3e1b971706df15eab3add359616a00634107760d57d19572b241af6443e55b92760032af0ebaeea017e1d017e3da5fa4ef2455a5d"; | |
function cookieSize(value) { | |
return encodeURIComponent('' + value).length; | |
} | |
function test1(value){ | |
data = {}; | |
cookieSize(value) == 36 ? data.mbid = value : (value == null) ? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function test2(value){ | |
data = {}; | |
((cookieSize(value)==36) || (value == null))? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function resultMbid(){ | |
data = {}; | |
data.mbid = testMbid; | |
return data; | |
} | |
function resultEid(){ | |
data = {}; | |
data.eid = testEid; | |
return data | |
} | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testMbid = "218dfc9e-c77f-4469-80e1-1037b4483601"; | |
var testEid = "01.1472232578.917805cc56ad4efdc3e1b971706df15eab3add359616a00634107760d57d19572b241af6443e55b92760032af0ebaeea017e1d017e3da5fa4ef2455a5d"; | |
function cookieSize(value) { | |
return encodeURIComponent('' + value).length; | |
} | |
function test1(value){ | |
data = {}; | |
cookieSize(value) == 36 ? data.mbid = value : (value == null) ? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function test2(value){ | |
data = {}; | |
((cookieSize(value)==36) || (value == null))? data.mbid = value : data.eid = value; | |
return data; | |
} | |
function resultMbid(){ | |
data = {}; | |
data.mbid = testMbid; | |
return data; | |
} | |
function resultEid(){ | |
data = {}; | |
data.eid = testEid; | |
return data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment