2015-08-29 04:32:56 +02:00
|
|
|
describe('Core helper tests', function() {
|
|
|
|
|
|
|
|
var helpers;
|
|
|
|
|
|
|
|
beforeAll(function() {
|
|
|
|
helpers = window.Chart.helpers;
|
|
|
|
});
|
|
|
|
|
2016-04-26 22:44:53 +02:00
|
|
|
it('should generate integer ids', function() {
|
|
|
|
var uid = helpers.uid();
|
|
|
|
expect(uid).toEqual(jasmine.any(Number));
|
|
|
|
expect(helpers.uid()).toBe(uid + 1);
|
|
|
|
expect(helpers.uid()).toBe(uid + 2);
|
|
|
|
expect(helpers.uid()).toBe(uid + 3);
|
2015-08-29 04:32:56 +02:00
|
|
|
});
|
2020-10-18 19:31:01 +02:00
|
|
|
|
|
|
|
describe('clone', function() {
|
|
|
|
it('should not allow prototype pollution', function() {
|
|
|
|
const test = helpers.clone(JSON.parse('{"__proto__":{"polluted": true}}'));
|
|
|
|
expect(test.prototype).toBeUndefined();
|
|
|
|
expect(Object.prototype.polluted).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
2015-10-17 05:14:07 +02:00
|
|
|
});
|