"use strict"; // We really, really, REALLY want not to load two separate // implementations of values.js into the same node.js instance, so // there's a bunch of singleton hackery in values.js. These tests // check that separate loads don't cause separate instances. const assert = require('assert'); const Immutable = require('immutable'); describe('reloading values.js', () => { const V1 = require('../src/values.js'); delete require.cache[require.resolve('../src/values.js')]; const V2 = require('../src/values.js'); const C1 = V1.Record.makeConstructor('c', ['a', 'b']); const C2 = V2.Record.makeConstructor('c', ['a', 'b']); it('should reuse RecordConstructorInfo (1)', () => { assert(C1.constructorInfo instanceof V1.RecordConstructorInfo); }); it('should reuse RecordConstructorInfo (2)', () => { assert(C1.constructorInfo instanceof V2.RecordConstructorInfo); }); it('should identify RecordConstructorInfo', () => { assert(Object.is(V1.RecordConstructorInfo, V2.RecordConstructorInfo)); }); it('should produce identical module instances', () => { assert.strictEqual(V1, V2); }); it('should produce distinct constructor instances', () => { assert.notStrictEqual(C1, C2); }); it('should produce distinct constructor info', () => { assert(!Object.is(C1.constructorInfo, C2.constructorInfo)); }); it('should produce compatible constructor info', () => { assert(Immutable.is(C1.constructorInfo, C2.constructorInfo)); }); it('should produce compatible record instances', () => { assert(Immutable.is(C1(1,2), C2(1,2))); }); }); describe('reloading index.js', () => { it('produces identical module exports objects', () => { const I1 = require('../src/index.js'); delete require.cache[require.resolve('../src/index.js')]; const I2 = require('../src/index.js'); assert(Object.is(I1, I2)); }); });