UNPKG

@userlab/dx

Version:

Build efficient GraphQL backend

35 lines (34 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var graphql_1 = require("graphql"); var utils_1 = require("../utils"); var fields = { id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) }, name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, roleId: { type: graphql_1.GraphQLID, sqlColumn: 'role_id' }, isDisabled: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean), sqlColumn: 'is_disabled', defaultValue: false, }, }; var values = { id: 'e8f547b6-10be-4eab-ae11-6833909631d4', name: 'Test Name', roleId: 'f71ddac9-7d03-407c-98ca-abf33ef2fab7', isDisabled: false, }; var sqlValues = { id: 'e8f547b6-10be-4eab-ae11-6833909631d4', name: 'Test Name', role_id: 'f71ddac9-7d03-407c-98ca-abf33ef2fab7', is_disabled: false, }; describe('orm utils', function () { test('fieldsToSqlColumn', function () { expect(utils_1.fieldsToSqlColumn(fields, values)).toEqual(sqlValues); }); test('sqlColumnToFields', function () { expect(utils_1.sqlColumnToFields(fields, sqlValues)).toEqual(values); }); });