This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PokemonScreen extends Component { | |
render() { | |
const { loading, error, myPokemon } = this.props.data; | |
if (loading) { | |
return <ActivityIndicator /> | |
} | |
if (error) { | |
return <ErrorScreen /> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /* 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"__schema": { | |
"queryType": { | |
"name": "Query" | |
}, | |
"mutationType": null, | |
"types": [ | |
{ | |
"kind": "OBJECT", | |
"name": "Query", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { gql } = require("apollo-server-express"); | |
const schemaString = gql` | |
scalar Date | |
enum PokemonType { | |
Normal | |
Fire | |
Water | |
Grass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const PORT = 8089; | |
let graphQLServerApp; | |
let httpServer; | |
function startHttpServer() { | |
return new Promise(resolve => { | |
httpServer = graphQLServerApp.listen(PORT, () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stopHttpServer() { | |
return new Promise(resolve => httpServer.close(() => resolve())); | |
} | |
async function stopGraphQLServer() { | |
if (!httpServer) { | |
console.warn("Tried to close null HTTP server."); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test non-max Pokemon level | |
{ | |
const defaultPokemon = { | |
Pokemon: () => ({ | |
level: 10 | |
}) | |
}; | |
//... | |
await startGraphQLServer({ ...defaultPokemon }); | |
} |
OlderNewer