Skip to content

Commit

Permalink
fix: normalize absolute path for windows, and enable local failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alharris-at committed Sep 21, 2023
1 parent 270bfaa commit 9872d43
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 35 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"update:integration-snapshots": "UPDATE_INTEGRATION_SNAPSHOTS=true tsx --test --test-reporter spec packages/integration-tests/lib/test-in-memory",
"update:tsconfig-refs": "tsx scripts/update_tsconfig_refs.ts",
"vend": "npm run start:npm-proxy && npm run publish:local",
"watch": "npm run build -- --watch"
"watch": "npm run build -- --watch",
"al": "npm run al:build && npm run al:test",
"al:build": "bash -c 'tsc --build packages/cli'",
"al:test": "bash -c 'npm run test:dir packages/cli/lib/commands/generate/graphql-client-code'"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ describe('generate graphql-client-code command', () => {
'graphql-client-code --stack stack_name --out /foo/bar'
);
assert.equal(generateClientConfigMock.mock.callCount(), 1);
assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
stackName: 'stack_name',
out: path.join('/', 'foo', 'bar'),
format: 'graphql-codegen',
statementTarget: 'javascript',
const actualInvocation =
generateClientConfigMock.mock.calls[0].arguments[0];
// normalize the path root across unix and windows platforms
const normalizedOutPath = actualInvocation?.out?.replace(
path.parse(actualInvocation?.out).root,
path.sep
);
const invocationWithNormalizedPath = actualInvocation;
assert.deepEqual(invocationWithNormalizedPath, {
...actualInvocation,
out: normalizedOutPath,
});
});

Expand Down Expand Up @@ -123,35 +129,41 @@ describe('generate graphql-client-code command', () => {
);
});

// it('can be invoked explicitly with graphql-codegen format', async () => {
// await commandRunner.runCommand('graphql-client-code --stack stack_name --format graphql-codegen');
// assert.equal(generateClientConfigMock.mock.callCount(), 1);
// assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
// stackName: 'stack_name',
// format: 'graphql-codegen',
// statementType: 'javascript',
// out: process.cwd(),
// });
// });
it('can be invoked explicitly with graphql-codegen format', async () => {
await commandRunner.runCommand(
'graphql-client-code --stack stack_name --format graphql-codegen'
);
assert.equal(generateClientConfigMock.mock.callCount(), 1);
assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
stackName: 'stack_name',
format: 'graphql-codegen',
statementType: 'javascript',
out: process.cwd(),
});
});

// it('can be invoked explicitly with modelgen format', async () => {
// await commandRunner.runCommand('graphql-client-code --stack stack_name --format modelgen');
// assert.equal(generateClientConfigMock.mock.callCount(), 1);
// assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
// stackName: 'stack_name',
// format: 'modelgen',
// modelType: 'javascript',
// out: process.cwd(),
// });
// });
it('can be invoked explicitly with modelgen format', async () => {
await commandRunner.runCommand(
'graphql-client-code --stack stack_name --format modelgen'
);
assert.equal(generateClientConfigMock.mock.callCount(), 1);
assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
stackName: 'stack_name',
format: 'modelgen',
modelType: 'javascript',
out: process.cwd(),
});
});

// it('can be invoked explicitly with introspection format', async () => {
// await commandRunner.runCommand('graphql-client-code --stack stack_name --format introspection');
// assert.equal(generateClientConfigMock.mock.callCount(), 1);
// assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
// stackName: 'stack_name',
// format: 'introspection',
// out: process.cwd(),
// });
// });
it('can be invoked explicitly with introspection format', async () => {
await commandRunner.runCommand(
'graphql-client-code --stack stack_name --format introspection'
);
assert.equal(generateClientConfigMock.mock.callCount(), 1);
assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], {
stackName: 'stack_name',
format: 'introspection',
out: process.cwd(),
});
});
});

0 comments on commit 9872d43

Please sign in to comment.