Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

assertRecord.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. var forEach = require('foreach');
  3. var debug = require('object-inspect');
  4. var assertRecord = require('../../helpers/assertRecord');
  5. var v = require('./values');
  6. module.exports = function assertRecordTests(ES, test) {
  7. test('Property Descriptor', function (t) {
  8. var record = 'Property Descriptor';
  9. forEach(v.nonUndefinedPrimitives, function (primitive) {
  10. t['throws'](
  11. function () { assertRecord(ES, record, 'arg', primitive); },
  12. TypeError,
  13. debug(primitive) + ' is not a Property Descriptor'
  14. );
  15. });
  16. t['throws'](
  17. function () { assertRecord(ES, record, 'arg', { invalid: true }); },
  18. TypeError,
  19. 'invalid keys not allowed on a Property Descriptor'
  20. );
  21. t.doesNotThrow(
  22. function () { assertRecord(ES, record, 'arg', {}); },
  23. 'empty object is an incomplete Property Descriptor'
  24. );
  25. t.doesNotThrow(
  26. function () { assertRecord(ES, record, 'arg', v.accessorDescriptor()); },
  27. 'accessor descriptor is a Property Descriptor'
  28. );
  29. t.doesNotThrow(
  30. function () { assertRecord(ES, record, 'arg', v.mutatorDescriptor()); },
  31. 'mutator descriptor is a Property Descriptor'
  32. );
  33. t.doesNotThrow(
  34. function () { assertRecord(ES, record, 'arg', v.dataDescriptor()); },
  35. 'data descriptor is a Property Descriptor'
  36. );
  37. t.doesNotThrow(
  38. function () { assertRecord(ES, record, 'arg', v.genericDescriptor()); },
  39. 'generic descriptor is a Property Descriptor'
  40. );
  41. t['throws'](
  42. function () { assertRecord(ES, record, 'arg', v.bothDescriptor()); },
  43. TypeError,
  44. 'a Property Descriptor can not be both a Data and an Accessor Descriptor'
  45. );
  46. t.end();
  47. });
  48. };