Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to support for usage from node #6

Merged
merged 18 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Change directory
  • Loading branch information
joachimdalen committed Dec 16, 2021
commit 50e01c1b91d0c2b6b48970341ac266acb9de0ac4
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config: Config.InitialOptions = {
transform: {
'^.+\\.ts?$': 'ts-jest'
},
collectCoverageFrom: ['src/**/*.ts', '!src/azext.ts'],
collectCoverageFrom: ['src/**/*.ts', '!src/azext.ts', '!src/tests/**'],
testEnvironment: 'node',
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts)$',
coveragePathIgnorePatterns: ['<rootDir>/node_modules'],
Expand Down
42 changes: 42 additions & 0 deletions src/tests/cli/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import AzExtCli from '../../cli/cli';

describe('AzExtCli', () => {
describe('parse', () => {
it('should return error when passing unknown root command', async () => {
const cli = new AzExtCli();
const result = cli.parse(['hummer', 'help']);

expect(result.isSuccess).toBeFalsy();
expect(result.message).toEqual('No such root command hummer');
});
it('should return error when unknown sub command', async () => {
const cli = new AzExtCli();
const result = cli.parse(['changelog']);

expect(result.isSuccess).toBeFalsy();
expect(result.message).toEqual('No such sub command undefined');
});
it('should return sub command when defined', async () => {
const cli = new AzExtCli();
const result = cli.parse(['changelog', 'generate']);

expect(result.isSuccess).toBeTruthy();
expect(result.data).toBeDefined();
expect(result.data?.command.handler).toBeDefined();
});

it('should parse options', async () => {
const cli = new AzExtCli();
const result = cli.parse([
'changelog',
'generate',
'--output',
'some-file.md'
]);

expect(result.isSuccess).toBeTruthy();
expect(result.data).toBeDefined();
expect(result.data?.rest?.options.output).toEqual('some-file.md');
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ConfigProvider from '../../src/data-providers/config-provider';
import path from 'path';
import ConfigProvider from '../../data-providers/config-provider';
const fs = require('fs').promises;

describe('ConfigProvider', () => {
Expand Down