Skip to content

Instantly share code, notes, and snippets.

View Farenheith's full-sized avatar

Thiago Oliveira Santos Farenheith

  • Grupo Boticário
  • São Paulo, Brazil
View GitHub Profile
import { EventEmitter } from 'events';
import { expect } from 'chai';
import { stub } from 'sinon';
import { eventEmitterExample } from '../src/event-emitter-example';
describe.only('eventEmitterExample()', () => {
beforeEach(() => {
stub(console, 'info');
stub(console, 'error');
@Farenheith
Farenheith / superagent-example.spec.ts
Created February 29, 2020 06:22
Example of test to the first example of code in https://visionmedia.github.io/superagent/
import { expect } from 'chai';
import { stub, match } from 'sinon';
import request = require('superagent');
import { superagentExample } from '../src/superagent-example';
describe('superAgentExample()', () => {
let requestResult: request.SuperAgentRequest;
beforeEach(() => {
requestResult = Promise.resolve({ body: 'expected body' }) as any;
import { expect } from 'chai';
import { stub, match, SinonStub } from 'sinon';
import request = require('superagent');
import { superagentExample } from '../src/superagent-example';
describe('superAgentExample()', () => {
let send: SinonStub;
let set1: SinonStub;
let set2: SinonStub;
export function anonymousExample(callbacker: (x: (v: number) => void) => void) {
callbacker((v) => {
if (v === 1) {
console.log('first v!');
} else {
console.log('another v!');
}
});
}
import { expect } from 'chai';
import { stub, match } from 'sinon';
import { anonymousExample } from '../src/anonymous-example';
describe('anonymousExample()', () => {
beforeEach(() => {
stub(console, 'log');
});
it('should log first v when v is 1', () => {
@Farenheith
Farenheith / launch.json
Last active September 2, 2024 00:51
Launch.json example for vscode using nvm to get node version directly from .nvmrc
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Launch program",
"skipFiles": ["<node_internals>/**"],
"cwd": "${workspaceRoot}",
"envFile": "${workspaceFolder}/.env",
"runtimeExecutable": "${env:NVM_DIR}/nvm-exec",