import {resolve} from "path"

import test from "ava"
import pq from "proxyquire"
import {GraphQLString as TString} from "graphql"

import Schema from "parasprite"

const mockIntrospectHelperDeps = (deps = {}) => pq(
  resolve(__dirname, "..", "..", "..", "helper/util/introspect"), {
    ...deps
  }
)

const schema = Schema()
  .query("Query")
    .resolve("phrase", TString, true, () => "Let's go, pal.")
    .end()
  .end()
.end()

test("Should have additional methods on default export", t => {
  t.plan(2)

  const introspect = mockIntrospectHelperDeps()

  t.is(typeof introspect.default.asObject, "function")
  t.is(typeof introspect.default.asJSON, "function")
})

test("Should return a promise", t => {
  t.plan(1)

  const introspect = mockIntrospectHelperDeps({
    fs: {
      writeFile() {
        // noop
      }
    }
  })

  const res = introspect.default(schema, __dirname, {spaces: 2})

  t.true(res instanceof Promise)
})

@@ -157,16 +157,65 @@
 prite%22%0A%0A
+import introspect from %22helper/util/introspect%22%0A%0A
 const mo
@@ -558,57 +558,8 @@
 2)%0A%0A
-  const introspect = mockIntrospectHelperDeps()%0A%0A
   t.
@@ -579,24 +579,16 @@
 rospect.
-default.
 asObject
@@ -630,16 +630,8 @@
 ect.
-default.
 asJS

Fix code coverage.