UNPKG

shared.js

Version:

A factory for a passive mediator design pattern in <25 lines of Javascript

33 lines (27 loc) 860 B
/** * Coded by: Andy (github.com/andy9775) */ 'use strict'; jest.autoMockOff(); var Shared = require('../index'); describe('Shared object test', function(){ it('Should not return undefined', function(){ expect(Shared.getShare()).toBeDefined(); }); it('Should set the initial property and value',function(){ var id= 'propertyTest'; var first = Shared.getShare(id, 'someProperty', 12); expect(first.someProperty).toEqual(12); }); it('Should return the same object based on the id argument', function(){ var id = 'shareIdTest2'; var first = Shared.getShare(id, 'sharedProperty', 5); var second = Shared.getShare(id); expect(first).toEqual(second); }); it('Should return a system wide object', function(){ var one = Shared.getShare(); var two = Shared.getShare(); expect(one).toEqual(two); }) });