Skip to content

Instantly share code, notes, and snippets.

View barsumek's full-sized avatar

Bartosz Sumper barsumek

View GitHub Profile
@barsumek
barsumek / mockSchema.js
Last active November 22, 2018 10:54
Detox your GraphQL: Mock schema
const { ApolloServer } = require("apollo-server-express");
const { buildClientSchema } = require("graphql");
const { resolvers } = require("./schema");
const introspectedSchema = require("./schemaExample.json");
const PORT = 8089;
function createServerWithMockedSchema(customMocks = {}) {
const schema = buildClientSchema(introspectedSchema);
@barsumek
barsumek / schema.js
Created November 22, 2018 10:27
Detox your GraphQL: Schema types definitions
const { gql } = require("apollo-server-express");
const schemaString = gql`
scalar Date
enum PokemonType {
Normal
Fire
Water
Grass
@barsumek
barsumek / schemaExample.json
Last active November 22, 2018 10:44
Detox your GraphQL: Schema example
{
"__schema": {
"queryType": {
"name": "Query"
},
"mutationType": null,
"types": [
{
"kind": "OBJECT",
"name": "Query",
@barsumek
barsumek / PokemonScreen.spec.js
Created November 22, 2018 10:17
Detox your GraphQL: Pokemon Screen test
// /* eslint-env detox/detox, mocha */
describe("Test Pokemon screen", () => {
beforeEach(async () => {
await device.reloadReactNative();
});
it("Display MaxLvl if the pokemon has maximum level.", async () => {
await expect(element(by.id("pokemonButton"))).toBeVisible();
await element(by.id("pokemonButton")).tap();
await expect(element(by.text("Level: MaxLvl"))).toBeVisible();
@barsumek
barsumek / PokemonScreen.js
Last active November 22, 2018 13:30
Detox your GraphQL: Pokemon Screen
class PokemonScreen extends Component {
render() {
const { loading, error, myPokemon } = this.props.data;
if (loading) {
return <ActivityIndicator />
}
if (error) {
return <ErrorScreen />
}
import java.time.format.DateTimeFormatter
import java.time.{LocalDate, LocalTime}
import scala.annotation.tailrec
object Sessions {
private val DateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
private val MinSessions = 6
private case class SessionDateTime(date: LocalDate, time: LocalTime)
object Sequences {
def filterPrimeCount(toFilter: Seq[Int], toCheckPrimeCount: Seq[Int]): Seq[Int] = {
def isPrime(num: Int): Boolean = {
require(num >= 0)
num match {
case n if n == 2 || n == 3 => true
case n if n < 2 || n % 2 == 0 => false
case _ => 5.to(math.sqrt(num).toInt, 2).forall(num % _ != 0)
}