2017-04-26 11:46:15 -05:00
|
|
|
const getGuid = require('../../js/utils/getGuid.js');
|
|
|
|
|
|
|
|
describe('guid tests', function() {
|
|
|
|
it('should have valid length', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const guid = getGuid();
|
2017-04-26 11:46:15 -05:00
|
|
|
expect(guid.length).toBe(36);
|
2017-08-24 02:51:02 -05:00
|
|
|
const parts = guid.split('-');
|
2017-04-26 11:46:15 -05:00
|
|
|
expect(parts.length).toBe(5);
|
|
|
|
expect(parts[0].length).toBe(8);
|
|
|
|
expect(parts[1].length).toBe(4);
|
|
|
|
expect(parts[2].length).toBe(4);
|
|
|
|
expect(parts[3].length).toBe(4);
|
|
|
|
expect(parts[4].length).toBe(12);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should only contains hex chars', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
for(let i = 0; i < 100; i++) {
|
|
|
|
const guid = getGuid();
|
|
|
|
const parts = guid.split('-');
|
2017-04-26 11:46:15 -05:00
|
|
|
parts.forEach(function(part) {
|
|
|
|
expect(/^([A-Fa-f0-9]{2})+$/.test(part)).toBe(true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|