objs.spec.js 791 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. /* jshint node:true, jasmine:true */
  9. 'use strict';
  10. var objs = require('../lib/objs');
  11. describe('The object manipulation library', function() {
  12. it('should allow lean copies', function() {
  13. var obj = {};
  14. expect(obj.hasOwnProperty).toBeDefined();
  15. var leanObj = objs.leanCopy(obj);
  16. expect(leanObj.hasOwnProperty).not.toBeDefined();
  17. });
  18. // Only run in supporting platforms
  19. if (Object.freeze) {
  20. it('should freeze objects', function() {
  21. var obj = objs.freeze({property: true});
  22. expect(function() {
  23. obj.property = false;
  24. }).toThrow();
  25. });
  26. }
  27. });