Example #1
0
  test('`waitUntilWatchIsReady` correctly handles `tsc` output', async () => {
    buildOutputStream.emit('data', Buffer.from('$ tsc'));
    buildOutputStream.emit('data', Buffer.from('Compilation complete.'));

    jest.runAllTimers();

    expect(await completionHintPromise).toBe('tsc');
  });
Example #2
0
  test('`waitUntilWatchIsReady` correctly handles `webpack` output', async () => {
    buildOutputStream.emit('data', Buffer.from('$ webpack'));
    buildOutputStream.emit('data', Buffer.from('Chunk Names'));

    jest.runAllTimers();

    expect(await completionHintPromise).toBe('webpack');
  });
Example #3
0
  test('`waitUntilWatchIsReady` fallbacks to default output handler if output is not recognizable', async () => {
    buildOutputStream.emit('data', Buffer.from('$ some-cli'));
    buildOutputStream.emit('data', Buffer.from('Compilation complete.'));
    buildOutputStream.emit('data', Buffer.from('Chunk Names.'));

    jest.runAllTimers();

    expect(await completionHintPromise).toBe('timeout');
  });
Example #4
0
 return () => {
   bag.dispose();
   if (input) {
     input.removeAllListeners();
   }
   if (output) {
     output.removeAllListeners();
   }
 };
window.addEventListener("storage", (event) => {
  if (event.key !== storageKey) return;

  const oldPub = pub;
  pub = JSON.parse(event.newValue);

  if (oldPub.keyMap !== pub.keyMap) emitter.emit("keyMap");
  if (oldPub.theme !== pub.theme) emitter.emit("theme");
});
Example #6
0
  return new Promise<any>((resolve, reject) => {
    emitter.once(event, (value: any) => {
      resolve(value);
    });

    emitter.once('error', (err: Error) => {
      reject(err);
    });
  });
Example #7
0
 zoneA.run(() => {
   emitter.on('removeListener', function(type: string, handler: any) {
     zoneResults.push('remove' + type);
   });
   emitter.on('test', shouldNotRun);
   emitter.on('test1', expectZoneA);
   emitter.removeAllListeners('test');
   expect(zoneResults).toEqual(['removetest']);
   expect(emitter.listeners('removeListener').length).toBe(1);
 });
Example #8
0
				response.on('end', function() {
					try {
						output = JSON.parse(content)
						emitter.emit('done', output)
					}
					catch (e) {
						e.cause = content
						emitter.emit('error', e)
					}
				})
Example #9
0
    it('.get with invalid service name and arguments', done => {
      const socket = new EventEmitter();

      provider.emit('connection', socket);

      socket.emit('get', null, (error: any) => {
        assert.strictEqual(error.name, 'NotFound');
        assert.strictEqual(error.message, `Service 'null' not found`);
        done();
      });
    });
Example #10
0
function addHandler(emitter: EventEmitter, event: string, handler: (...args: Array<any>) => void) {
  if (isLogEvent) {
    emitter.on(event, (...args: Array<any>) => {
      console.log("%s %s", event, args)
      handler.apply(null, args)
    })
  }
  else {
    emitter.on(event, handler)
  }
}