-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add unit tests for script-get command
...
- Loading branch information
Göran Sander
committed
Nov 22, 2023
1 parent
3556a55
commit 855b714
Showing
2 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable no-console */ | ||
const { test, expect, describe } = require('@jest/globals'); | ||
|
||
const { getScript } = require('../lib/cmd/getscript'); | ||
|
||
const options = { | ||
logLevel: process.env.CTRL_Q_LOG_LEVEL || 'info', | ||
authType: process.env.CTRL_Q_AUTH_TYPE || 'cert', | ||
host: process.env.CTRL_Q_HOST || '', | ||
port: process.env.CTRL_Q_PORT || '4747', | ||
virtualProxy: process.env.CTRL_Q_VIRTUAL_PROXY || '', | ||
secure: process.env.CTRL_Q_SECURE || true, | ||
schemaVersion: process.env.CTRL_Q_SCHEMA_VERSION || '12.612.0', | ||
appId: process.env.CTRL_Q_APP_ID || 'a3e0f5d2-000a-464f-998d-33d333b175d7', | ||
authUserDir: process.env.CTRL_Q_AUTH_USER_DIR || '', | ||
authUserId: process.env.CTRL_Q_AUTH_USER_ID || '', | ||
authJwt: process.env.CTRL_Q_AUTH_JWT || '', | ||
}; | ||
|
||
const defaultTestTimeout = process.env.CTRL_Q_TEST_TIMEOUT || 120000; // 2 minute default timeout | ||
jest.setTimeout(defaultTestTimeout); | ||
|
||
// Get app script | ||
describe('get app script (cert auth)', () => { | ||
options.authType = 'jwt'; | ||
options.port = '443'; | ||
options.virtualProxy = 'jwt'; | ||
|
||
test('Verify parameters', async () => { | ||
expect(options.host).not.toHaveLength(0); | ||
expect(options.authUserDir).not.toHaveLength(0); | ||
expect(options.authUserId).not.toHaveLength(0); | ||
}); | ||
|
||
/** | ||
* Get app script | ||
* Should succeed | ||
*/ | ||
test('get app script', async () => { | ||
const result = await getScript(options); | ||
|
||
expect(result.appId).toBe('a3e0f5d2-000a-464f-998d-33d333b175d7'); | ||
expect(result.appCreatedDate).toBe('2021-06-03T22:04:52.283Z'); | ||
expect(result.appModifiedDate).toBe('2023-05-05T06:17:05.456Z'); | ||
expect(result.appScript.length).toBe(1989); | ||
}); | ||
}); |