-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathconvertToOpossum.test.ts
40 lines (34 loc) · 1.62 KB
/
convertToOpossum.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
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import { existsSync } from 'fs';
import { uniqueId } from 'lodash';
import { tmpdir } from 'os';
import { join } from 'path';
import { parseOpossumFile } from '../../input/parseFile';
import { isOpossumFileFormat } from '../../utils/isOpossumFileFormat';
import {
convertOwaspToOpossum,
convertScancodeToOpossum,
} from '../convertToOpossum';
describe('conversion to opossum', () => {
const SCANCODE_TEST_FILE = join(__dirname, 'scancode.json');
const OWASP_TEST_FILE = join(__dirname, 'owasp-dependency-check-report.json');
it('should convert the ScanCode file and return a path to a valid .opossum file', async () => {
const opossumPath = join(tmpdir(), `${uniqueId('opossum_')}.opossum`);
await convertScancodeToOpossum(SCANCODE_TEST_FILE, opossumPath);
expect(existsSync(opossumPath)).toBe(true);
expect(isOpossumFileFormat(opossumPath)).toBe(true);
const parsingResult = await parseOpossumFile(opossumPath);
expect(parsingResult).toHaveProperty('input');
});
it('should convert the owasp file and return a path to a valid .opossum file', async () => {
const opossumPath = join(tmpdir(), `${uniqueId('opossum_')}.opossum`);
await convertOwaspToOpossum(OWASP_TEST_FILE, opossumPath);
expect(existsSync(opossumPath)).toBe(true);
expect(isOpossumFileFormat(opossumPath)).toBe(true);
const parsingResult = await parseOpossumFile(opossumPath);
expect(parsingResult).toHaveProperty('input');
});
});