@contrail/flexplm 1.7.4-alpha.368c8b1 → 1.7.4-alpha.aaaa660
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,6 +59,11 @@ describe('ConfigCreateCommand', () => {
|
|
|
59
59
|
expect(config.orgName).toEqual('acme');
|
|
60
60
|
expect(config.appIdentifier).toEqual('@vibeiq/flexplm-connector');
|
|
61
61
|
});
|
|
62
|
+
it('trims whitespace around the orgName input', async () => {
|
|
63
|
+
answers = [' acme ', '@vibeiq/flexplm-connector'];
|
|
64
|
+
await new config_create_1.ConfigCreateCommand().run();
|
|
65
|
+
expect(fs.existsSync(path.join(tempDir, 'acme-flexplmConfig.json'))).toBe(true);
|
|
66
|
+
});
|
|
62
67
|
it('defaults appIdentifier to @vibeiq/flexplm-connector when left blank', async () => {
|
|
63
68
|
answers = ['acme', ''];
|
|
64
69
|
await new config_create_1.ConfigCreateCommand().run();
|
|
@@ -26,6 +26,16 @@ describe('ConfigUploadCommand.parseArgs', () => {
|
|
|
26
26
|
const opts = config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '-b', 'feature/x']);
|
|
27
27
|
expect(opts.branch).toEqual('feature/x');
|
|
28
28
|
});
|
|
29
|
+
it('parses options before the file path', () => {
|
|
30
|
+
const opts = config_upload_1.ConfigUploadCommand.parseArgs(['-m', 'msg', '-b', 'br', 'config.json']);
|
|
31
|
+
expect(opts).toEqual({
|
|
32
|
+
filePath: 'config.json',
|
|
33
|
+
message: 'msg',
|
|
34
|
+
branch: 'br',
|
|
35
|
+
skipGit: false,
|
|
36
|
+
updateConfig: false,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
29
39
|
it('parses --skip-git flag', () => {
|
|
30
40
|
const opts = config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '--skip-git']);
|
|
31
41
|
expect(opts.skipGit).toBe(true);
|
|
@@ -38,24 +48,50 @@ describe('ConfigUploadCommand.parseArgs', () => {
|
|
|
38
48
|
const opts = config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '--update-config']);
|
|
39
49
|
expect(opts.updateConfig).toBe(true);
|
|
40
50
|
});
|
|
51
|
+
it('parses all options together', () => {
|
|
52
|
+
const opts = config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '-m', 'msg', '-b', 'br', '--skip-git', '--update-config']);
|
|
53
|
+
expect(opts).toEqual({
|
|
54
|
+
filePath: 'config.json',
|
|
55
|
+
message: 'msg',
|
|
56
|
+
branch: 'br',
|
|
57
|
+
skipGit: true,
|
|
58
|
+
updateConfig: true,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
41
61
|
it('throws when -m is missing its value', () => {
|
|
42
62
|
expect(() => config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '-m'])).toThrow(/-m requires a commit message/);
|
|
43
63
|
});
|
|
64
|
+
it('throws when -b is missing its value', () => {
|
|
65
|
+
expect(() => config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '-b'])).toThrow(/-b requires a branch name/);
|
|
66
|
+
});
|
|
44
67
|
it('throws on unknown option', () => {
|
|
45
68
|
expect(() => config_upload_1.ConfigUploadCommand.parseArgs(['config.json', '--bogus'])).toThrow(/Unknown option: --bogus/);
|
|
46
69
|
});
|
|
70
|
+
it('throws when an extra positional argument is supplied', () => {
|
|
71
|
+
expect(() => config_upload_1.ConfigUploadCommand.parseArgs(['config.json', 'extra.json'])).toThrow(/Unexpected argument: extra\.json/);
|
|
72
|
+
});
|
|
47
73
|
it('throws when no file path is provided', () => {
|
|
48
74
|
expect(() => config_upload_1.ConfigUploadCommand.parseArgs([])).toThrow(/missing <path\.json>/);
|
|
49
75
|
});
|
|
76
|
+
it('throws when only options are provided', () => {
|
|
77
|
+
expect(() => config_upload_1.ConfigUploadCommand.parseArgs(['--skip-git'])).toThrow(/missing <path\.json>/);
|
|
78
|
+
});
|
|
50
79
|
});
|
|
51
80
|
describe('ConfigUploadCommand.buildCommitMessage', () => {
|
|
52
81
|
it('appends fileId to the first line of a single-line message', () => {
|
|
53
82
|
expect(config_upload_1.ConfigUploadCommand.buildCommitMessage('initial commit', 'abc123')).toEqual('initial commit [fileId: abc123]');
|
|
54
83
|
});
|
|
84
|
+
it('only appends fileId to the first line of a multi-line message', () => {
|
|
85
|
+
const result = config_upload_1.ConfigUploadCommand.buildCommitMessage('header line\nbody line 1\nbody line 2', 'xyz');
|
|
86
|
+
expect(result).toEqual('header line [fileId: xyz]\nbody line 1\nbody line 2');
|
|
87
|
+
});
|
|
55
88
|
it('handles CRLF line endings', () => {
|
|
56
89
|
const result = config_upload_1.ConfigUploadCommand.buildCommitMessage('header\r\nbody', 'fid');
|
|
57
90
|
expect(result).toEqual('header [fileId: fid]\nbody');
|
|
58
91
|
});
|
|
92
|
+
it('handles an empty message', () => {
|
|
93
|
+
expect(config_upload_1.ConfigUploadCommand.buildCommitMessage('', 'fid')).toEqual(' [fileId: fid]');
|
|
94
|
+
});
|
|
59
95
|
});
|
|
60
96
|
describe('ConfigUploadCommand.run', () => {
|
|
61
97
|
const fs = require('fs');
|