import { expect } from 'chai'; import { describe, it, before, after } from 'mocha'; import { addServerUrlToIndex } from '../../../../../server/lib/omnichannel/Assets'; describe('addServerUrlToIndex', () => { before(() => { (global as any).__meteor_runtime_config__ = { ROOT_URL: 'http://localhost:3000' }; }); after(() => { delete (global as any).__meteor_runtime_config__; }); it('should do nothing if "file" has no tag', () => { const file = addServerUrlToIndex('file'); expect(file).to.equal('file'); }); it('should replace with an script tag containing the SERVER_URL inside', () => { const file = addServerUrlToIndex(''); expect(file).to.equal(""); }); it('should remove any trailing / from the SERVER_URL', () => { (global as any).__meteor_runtime_config__ = { ROOT_URL: 'http://localhost:3000/' }; const file = addServerUrlToIndex(''); expect(file).to.equal(""); }); it('should use the value from the global variable always', () => { const file = addServerUrlToIndex(''); expect(file).to.equal(""); (global as any).__meteor_runtime_config__ = { ROOT_URL: 'http://kodiak.rocket.chat/' }; const file2 = addServerUrlToIndex(''); expect(file2).to.equal(""); }); });