| 
 | 1 | +// SPDX-License-Identifier: MIT  | 
 | 2 | +/*  | 
 | 3 | +   Copyright (c) 2025, SCANOSS  | 
 | 4 | +
  | 
 | 5 | +   Permission is hereby granted, free of charge, to any person obtaining a copy  | 
 | 6 | +   of this software and associated documentation files (the "Software"), to deal  | 
 | 7 | +   in the Software without restriction, including without limitation the rights  | 
 | 8 | +   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  | 
 | 9 | +   copies of the Software, and to permit persons to whom the Software is  | 
 | 10 | +   furnished to do so, subject to the following conditions:  | 
 | 11 | +
  | 
 | 12 | +   The above copyright notice and this permission notice shall be included in  | 
 | 13 | +   all copies or substantial portions of the Software.  | 
 | 14 | +
  | 
 | 15 | +   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  | 
 | 16 | +   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  | 
 | 17 | +   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  | 
 | 18 | +   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  | 
 | 19 | +   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  | 
 | 20 | +   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN  | 
 | 21 | +   THE SOFTWARE.  | 
 | 22 | + */  | 
 | 23 | + | 
 | 24 | +/**  | 
 | 25 | + * Unit tests for the action's main functionality, src/main.ts  | 
 | 26 | + *  | 
 | 27 | + * These should be run as if the action was called from a workflow.  | 
 | 28 | + * Specifically, the inputs listed in `action.yml` should be set as environment  | 
 | 29 | + * variables following the pattern `INPUT_<INPUT_NAME>`.  | 
 | 30 | + */  | 
 | 31 | + | 
 | 32 | +// import * as core from '@actions/core';  | 
 | 33 | +// import * as main from '../src/main';  | 
 | 34 | +//  | 
 | 35 | +// // Mock the action's main function  | 
 | 36 | +// const runMock = jest.spyOn(main, 'run');  | 
 | 37 | +//  | 
 | 38 | +// // Mock the GitHub Actions core library  | 
 | 39 | +// let debugMock: jest.SpyInstance;  | 
 | 40 | +// let getInputMock: jest.SpyInstance;  | 
 | 41 | +// let setFailedMock: jest.SpyInstance;  | 
 | 42 | +// let setOutputMock: jest.SpyInstance;  | 
 | 43 | + | 
 | 44 | +// TODO Is this test necessary?  | 
 | 45 | +// describe('action', () => {  | 
 | 46 | +//   beforeEach(() => {  | 
 | 47 | +//     jest.clearAllMocks();  | 
 | 48 | +//  | 
 | 49 | +//     debugMock = jest.spyOn(core, 'debug').mockImplementation();  | 
 | 50 | +//     getInputMock = jest.spyOn(core, 'getInput').mockImplementation();  | 
 | 51 | +//     // setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation();  | 
 | 52 | +//     // setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation();  | 
 | 53 | +//   });  | 
 | 54 | +//  | 
 | 55 | +//   it('SCANOSS Scan Action started', async () => {  | 
 | 56 | +//     // Set the action's inputs as return values from core.getInput()  | 
 | 57 | +//     getInputMock.mockImplementation((name: string): string => {  | 
 | 58 | +//       switch (name) {  | 
 | 59 | +//         case 'scanner-parameters':  | 
 | 60 | +//           return '';  | 
 | 61 | +//         case 'scanFiles':  | 
 | 62 | +//           return 'true'; // Enable file scanning to pass validation  | 
 | 63 | +//         case 'dependencies.enabled':  | 
 | 64 | +//           return 'true'; // Enable dependency scanning as backup  | 
 | 65 | +//         case 'policies':  | 
 | 66 | +//           return 'copyleft'; // Set a policy to avoid "No policies specified"  | 
 | 67 | +//         default:  | 
 | 68 | +//           return '';  | 
 | 69 | +//       }  | 
 | 70 | +//     });  | 
 | 71 | +//  | 
 | 72 | +//     await main.run();  | 
 | 73 | +//     expect(runMock).toHaveReturned();  | 
 | 74 | +//  | 
 | 75 | +//     // Verify that all of the core library functions were called correctly  | 
 | 76 | +//     expect(debugMock).toHaveBeenNthCalledWith(1, 'SCANOSS Scan Action started...');  | 
 | 77 | +//     // Note: The test environment doesn't have Docker, so scan execution will fail  | 
 | 78 | +//     // The important thing is that the action started and basic validation passed  | 
 | 79 | +//   });  | 
 | 80 | +// });  | 
0 commit comments