2
0

objects.spec.js 836 B

123456789101112131415161718192021222324252627282930313233
  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 expect = require('chai').expect;
  11. var objects = require('../lib/objects');
  12. describe('The object manipulation library', function() {
  13. it('should allow lean copies', function() {
  14. var obj = {
  15. aFunction: function() {}
  16. };
  17. expect(obj.hasOwnProperty).to.exist;
  18. var leanObj = objects.leanCopy(obj);
  19. expect(leanObj.hasOwnProperty).to.not.exist;
  20. expect(leanObj.aFunction).to.not.exist;
  21. });
  22. it('should freeze objects', function() {
  23. var obj = objects.freeze({property: true});
  24. expect(function() {
  25. obj.property = false;
  26. }).to.throw();
  27. });
  28. });