-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ability to filter files from automated checks (#613)
* feat: add ability to filter files from automated checks st framework level * test: added few tests for helper.js * test: added tests for helper.ts * fix: concat the useFilesToBeExempted() and autoCheckOpts.filesFilter * fix: modified a test in automatic.test.ts * fix: updated setup.ts * fix: changed helpers.ts to fix the lint issue * Update helpers.ts * Update automatic.test.ts * Update setup.ts --------- Co-authored-by: Navateja Alagam <navateja215@gmail.com>
- Loading branch information
1 parent
b444195
commit a0f52d8
Showing
6 changed files
with
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { useFilesToBeExempted, log } from '../src/helpers'; | ||
|
||
describe('Your Module', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('should log messages when SA11Y_DEBUG is set', () => { | ||
const originalEnv = process.env.SA11Y_DEBUG; | ||
process.env.SA11Y_DEBUG = 'true'; | ||
|
||
const consoleSpy = jest.spyOn(console, 'log'); | ||
log('Test Log Message'); | ||
|
||
expect(consoleSpy).toHaveBeenCalledWith('♿[Sa11y]', 'Test Log Message'); | ||
|
||
process.env.SA11Y_DEBUG = originalEnv; // Restore original environment variable | ||
}); | ||
|
||
it('should return an empty array if packageName is not set', () => { | ||
const result = useFilesToBeExempted(); | ||
|
||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should return an empty array if SA11Y_AUTO_FILTER_LIST_PACKAGE_REQUIREMENT is not set', () => { | ||
process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME = 'somePackage'; | ||
process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_REQUIREMENT = ''; | ||
|
||
const result = useFilesToBeExempted(); | ||
|
||
expect(result).toEqual([]); | ||
|
||
// Cleanup | ||
delete process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_REQUIREMENT; | ||
delete process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME; | ||
}); | ||
|
||
it('should use the package if packageName is set', () => { | ||
const packageName = '../testMocks/packageTestHelper.ts'; | ||
process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME = packageName; | ||
|
||
const result = useFilesToBeExempted(); | ||
|
||
expect(result).toEqual(['file1', 'file2']); | ||
|
||
// Cleanup | ||
delete process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME; | ||
}); | ||
|
||
it('no package found if packageName is set', () => { | ||
const packageName = '../testMocks/packageTestHelperWrong.ts'; | ||
|
||
process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME = packageName; | ||
|
||
const result = useFilesToBeExempted(); | ||
|
||
expect(result).toEqual([]); | ||
// Cleanup | ||
delete process.env.SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME; | ||
}); | ||
}); |
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
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,9 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
const getFilesToBeExempted = () => ['file1', 'file2']; | ||
|
||
module.exports = getFilesToBeExempted; |
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