This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
generated from actions/javascript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
45 lines (38 loc) · 1.61 KB
/
index.test.js
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
const findFabricVersion = require('./version');
const process = require('process');
const cp = require('child_process');
const path = require('path');
test('throws invalid version', async () => {
await expect(findFabricVersion(123)).rejects.toThrow('minecraftVersion not a string');
});
test('throws missing version', async () => {
await expect(findFabricVersion('99.99.99')).rejects.toThrow("No version found for 99.99.99");
});
test('get exact api version', async () => {
const {apiVersion} = await findFabricVersion('1.17');
expect(apiVersion).toBe('0.46.1+1.17');
});
test('get previous minor api version', async () => {
const {apiVersion} = await findFabricVersion('1.17.1');
expect(apiVersion).toBe('0.46.1+1.17');
});
test('get base api version', async () => {
const {apiVersion} = await findFabricVersion('1.16.2');
expect(apiVersion).toBe('0.42.0+1.16');
});
test('get loader version', async () => {
const {loaderVersion} = await findFabricVersion('1.19.2');
const loaderVersionParts = loaderVersion.split('.');
expect(loaderVersionParts.length).toBeGreaterThanOrEqual(2);
expect(parseInt(loaderVersionParts[0])).toBeGreaterThanOrEqual(0);
if(loaderVersionParts[0] === '0') {
expect(parseInt(loaderVersionParts[1])).toBeGreaterThanOrEqual(14);
}
});
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MINECRAFTVERSION'] = '1.16.5';
const ip = path.join(__dirname, 'index.js');
const result = cp.execSync(`node "${ip}"`, {env: process.env}).toString();
console.log(result);
})