Skip to content

Instantly share code, notes, and snippets.

View 0xR's full-sized avatar

Ruben Oostinga 0xR

View GitHub Profile
@0xR
0xR / VertXAndReactor.kt
Last active November 13, 2019 14:50
Vert.X streams with Reactor
fun <Input, Output> processWithReactor(
vertx: Vertx,
inputStream: ReadStream<Input>,
outputStream: WriteStream<Output>,
processor: (Flux<Input>) -> Flux<Output>
) {
val publisher = ReactiveWriteStream.writeStream<Input>(vertx)
inputStream.pipeTo(publisher)
val writeStreamFlux = Flux.from(publisher)
// Chai
expect({ a: 1 }).to.deep.equal({ a: 1 });
expect({ a: 1 }).not.to.deep.equal({ a: 2 });
// Jest / jasmine
expect({ a: 1 }).toEqual({ a: 1 });
expect({ a: 1 }).not.toEqual({ a: 2 });
expect(json).toMatchSnapshot();
// Make sure chai and jasmine ".not" play nice together
const originalNot = Object.getOwnPropertyDescriptor(chai.Assertion.prototype, 'not').get;
Object.defineProperty(chai.Assertion.prototype, 'not', {
get() {
Object.assign(this, this.assignedNot);
return originalNot.apply(this);
},
set(newNot) {
this.assignedNot = newNot;
return newNot;
global.jestExpect = global.expect;
global.expect = chai.expect;
@0xR
0xR / App.spec.jsx
Last active November 2, 2016 16:43
expect({ a: 1 }).to.deep.equal({ a: 1 });
jestExpect({ a: 1 }).toEqual({ a: 1 });
// Usage: import makeTypeDef from './graphql-schema-creator.js';
// makeTypeDef('mynewtype', myTypeValue);
import {
GraphQLObjectType,
GraphQLNonNull,
GraphQLSchema,
GraphQLString,
GraphQLList,
GraphQLInt,