Skip to content

Commit

Permalink
Go
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed May 14, 2024
1 parent 1e7c011 commit c351b77
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions packages/load/tests/loaders/schema/schema-from-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,77 @@ describe('Schema From Export', () => {
sync: loadSchemaSync,
})((load, mode) => {
test('should load the schema correctly from module.exports', async () => {
const result = await load('./tests/loaders/schema/test-files/loaders/module-exports.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/module-exports.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
});

test('should load the schema (with extend) correctly from module.exports', async () => {
const result = await load('./tests/loaders/schema/test-files/schema-dir/with-extend.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/with-extend.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
const QueryType = result.getQueryType();
assertNonMaybe(QueryType);
expect(QueryType.getFields()['hello']).toBeDefined();
});

test('should load the schema correctly from variable export', async () => {
const result = await load('./tests/loaders/schema/test-files/loaders/schema-export.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/schema-export.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
});

test('should load the schema correctly from default export', async () => {
const result = await load('./tests/loaders/schema/test-files/loaders/default-export.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/default-export.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
});

if (mode === 'async') {
test('should load the schema correctly from promise export', async () => {
const result = await load('./tests/loaders/schema/test-files/loaders/promise-export.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/promise-export.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
});

test('should load the schema correctly from promise export', async () => {
const result = await load('./tests/loaders/schema/test-files/loaders/promise-export.js', {
loaders: [new CodeFileLoader()],
});
const result = await load(
'../../../../loaders/code-file/tests/test-files/loaders/promise-export.js',
{
loaders: [new CodeFileLoader()],
cwd: __dirname,
},
);
expect(isSchema(result)).toBeTruthy();
});
}

test.only('should work with extensions (without schema definition)', async () => {
test('should work with extensions (without schema definition)', async () => {
const schemaPath = './tests/loaders/schema/test-files/schema-dir/extensions/export-schema.js';
const schema = await load(schemaPath, {
loaders: [new CodeFileLoader()],
Expand All @@ -80,7 +104,7 @@ describe('Schema From Export', () => {
expect(queryFields).toContain('bar');
});

test.only('should work with extensions (with schema definition)', async () => {
test('should work with extensions (with schema definition)', async () => {
const schemaPath =
'./tests/loaders/schema/test-files/schema-dir/extensions/export-schema-with-def.js';
const schema = await load(schemaPath, {
Expand Down

0 comments on commit c351b77

Please sign in to comment.