index.js 929 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var test = require('tape');
  3. var inspect = require('object-inspect');
  4. var forEach = require('for-each');
  5. var isFinalizationRegistry = require('..');
  6. test('isFinalizationRegistry', function (t) {
  7. t.equal(typeof isFinalizationRegistry, 'function', 'is a function');
  8. var nonFinalizationRegistries = [undefined, null, true, false, 42, 0, Infinity, NaN, /a/g, function () {}, {}, []];
  9. forEach(nonFinalizationRegistries, function (nonFinalizationRegistry) {
  10. t.equal(isFinalizationRegistry(nonFinalizationRegistry), false, inspect(nonFinalizationRegistry) + ' is not a FinalizationRegistry');
  11. });
  12. t.test('actual FinalizationRegistry instances', { skip: typeof FinalizationRegistry === 'undefined' }, function (st) {
  13. var registry = new FinalizationRegistry(function () {});
  14. st.equal(isFinalizationRegistry(registry), true, inspect(registry) + ' is a FinalizationRegistry');
  15. st.end();
  16. });
  17. t.end();
  18. });