All Downloads are FREE. Search and download functionalities are using the official Maven repository.

node_modules.graphql-config.lib.__tests__.basic.getGraphQLConfig.js Maven / Gradle / Ivy

There is a newer version: 3.3.1
Show newest version
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ava_1 = require("ava");
var path_1 = require("path");
var graphql_1 = require("graphql");
var _1 = require("../../");
var CONFIG_DIR = path_1.join(__dirname, 'config');
var config;
ava_1.default.beforeEach(function () {
    config = _1.getGraphQLConfig(CONFIG_DIR);
});
ava_1.default('returns a correct name', function (t) {
    var testWithSchemaConfig = config.getProjectConfig('testWithSchema');
    t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema');
});
ava_1.default('returns config for file', function (t) {
    var testWithSchemaConfig = config.getConfigForFile(path_1.resolve('./config/schema-a.graphql'));
    if (testWithSchemaConfig) {
        t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema');
    }
    else {
        t.fail();
    }
});
ava_1.default('returns a correct root dir', function (t) {
    t.deepEqual(config.configDir, CONFIG_DIR);
});
ava_1.default('returns a correct schema path', function (t) {
    t.deepEqual(config.getProjectConfig('testWithSchema').schemaPath, path_1.join(CONFIG_DIR, '__schema__/StarWarsSchema.graphql'));
    t.deepEqual(config.getProjectConfig('testWithoutSchema').schemaPath, null);
});
ava_1.default('reads single schema', function (t) {
    var typeDefs = "type Query {\n  hello: String!\n}\n";
    t.is(graphql_1.printSchema(config.getProjectConfig('testSchemaA').getSchema()), typeDefs);
});
ava_1.default('reads imported schema', function (t) {
    var typeDefs = "type Query {\n  hello: String!\n  user: User!\n}\n\ntype User {\n  name: String\n}\n";
    t.is(graphql_1.printSchema(config.getProjectConfig('testSchemaB').getSchema()), typeDefs);
});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy