generated from shadow578/typescript-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentationExamples.test.ts
48 lines (42 loc) · 1.19 KB
/
DocumentationExamples.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable @typescript-eslint/no-unused-vars */
import { isString } from '@shadow578/type-guardian/lib/TypeGuards';
import { PowerShellCall, PS, psCall, PowerShellBinding, DefaultShim, Shim } from '../index';
/**
* example powershell bindings
*/
class MyBinding extends PowerShellBinding {
/**
* greets a person
*
* @param name the name of the person to greet
* @returns a greeting for the person
*/
@PowerShellCall('Write-Output "Hello, $name!"', isString)
greet(name: string) {
return psCall<string>();
}
/**
* get the powershell version running in the binding
*
* @returns the powershell version
*/
@PS('Write-Output $PSVersionTable.PSVersion.ToString()', isString)
getPowerShellVersion() {
return psCall<string>();
}
}
let binding: MyBinding;
beforeAll(() => {
binding = new MyBinding();
});
afterAll(() => {
binding.shell.dispose();
});
describe('examples in README', () => {
test('should greet the world', async () => {
await expect(binding.greet('World')).resolves.toBe('Hello, World!');
});
test('should get the powershell version', async () => {
await expect(binding.getPowerShellVersion()).resolves.toBeDefined();
});
});