Skip to content

Commit

Permalink
test: remove wasm test
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 committed May 2, 2024
1 parent 44d0465 commit 579e656
Showing 1 changed file with 39 additions and 48 deletions.
87 changes: 39 additions & 48 deletions tailcall-cloudflare/tests/cf_tests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,52 @@
import {describe, test, expect} from "vitest"
import {describe, expect, test} from "vitest"
import {readFile} from "fs/promises"
import {mf} from "./mf"

describe("fetch", () => {
test("loadfiles", async () => {
let placeholder = (await readFile("../examples/jsonplaceholder.graphql")).toString()
let placeholder_batch = (await readFile("../examples/jsonplaceholder_batch.graphql")).toString()
let grpc = (await readFile("../examples/grpc.graphql")).toString()
let news_proto = (await readFile("../tailcall-fixtures/fixtures/protobuf/news.proto")).toString()
test("loadfiles", async () => {
let placeholder = (await readFile("../examples/jsonplaceholder.graphql")).toString()
let placeholder_batch = (await readFile("../examples/jsonplaceholder_batch.graphql")).toString()
let grpc = (await readFile("../examples/grpc.graphql")).toString()
let news_proto = (await readFile("../tailcall-fixtures/fixtures/protobuf/news.proto")).toString()

let bucket = await mf.getR2Bucket("MY_R2")
await bucket.put("examples/grpc.graphql", grpc)
await bucket.put("examples/../tailcall-fixtures/fixtures/protobuf/news.proto", news_proto)
await bucket.put("tailcall-fixtures/fixtures/protobuf/news.proto", grpc)
await bucket.put("examples/jsonplaceholder.graphql", placeholder)
await bucket.put("examples/jsonplaceholder_batch.graphql", placeholder_batch)
})

test("ide", async () => {
let resp = await mf.dispatchFetch("https://fake.host/", {
method: "GET",
let bucket = await mf.getR2Bucket("MY_R2")
await bucket.put("examples/grpc.graphql", grpc)
await bucket.put("examples/../tailcall-fixtures/fixtures/protobuf/news.proto", news_proto)
await bucket.put("tailcall-fixtures/fixtures/protobuf/news.proto", grpc)
await bucket.put("examples/jsonplaceholder.graphql", placeholder)
await bucket.put("examples/jsonplaceholder_batch.graphql", placeholder_batch)
})
let body = await resp.text()
expect(body.includes("<title>Tailcall - GraphQL IDE</title>")).toBe(true)
expect(resp.status).toBe(200)
})

test("sample_resp", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder.graphql", {
method: "POST",
body: '{"query":"{user(id: 1) {id}}"}',
test("sample_resp", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder.graphql", {
method: "POST",
body: '{"query":"{user(id: 1) {id}}"}',
})
let body = await resp.json()
let expected = {data: {user: {id: 1}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})
let body = await resp.json()
let expected = {data: {user: {id: 1}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})

test("test_batching", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder_batch.graphql", {
method: "POST",
body: '{"query":"{ posts { id } }"}',
test("test_batching", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder_batch.graphql", {
method: "POST",
body: '{"query":"{ posts { id } }"}',
})
let body = await resp.json()
let expected = {data: {posts: [{id: 1}]}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})
let body = await resp.json()
let expected = {data: {posts: [{id: 1}]}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})

test("test_grpc", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/grpc.graphql", {
method: "POST",
body: '{"query":"{ news { news { id } } }"}',
test("test_grpc", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/grpc.graphql", {
method: "POST",
body: '{"query":"{ news { news { id } } }"}',
})
let body = await resp.json()
let expected = {data: {news: {news: [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}]}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})
let body = await resp.json()
let expected = {data: {news: {news: [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}]}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})
})

0 comments on commit 579e656

Please sign in to comment.