ci/cd: trigger URL checks more, and limit amount
Key changes: - Run URL checks more frequently on every change. - Introduce environment variable to randomly select and limit URLs tested, this way the tests will provide quicker feedback on code changes. Other supporting changes: - Log more information about test before running the test to enable easier troubleshooting. - Move shuffle function for arrays for reusability and missing tests.
This commit is contained in:
52
tests/unit/application/Common/Shuffle.spec.ts
Normal file
52
tests/unit/application/Common/Shuffle.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shuffle } from '@/application/Common/Shuffle';
|
||||
|
||||
describe('Shuffle', () => {
|
||||
describe('shuffle', () => {
|
||||
it('returns a new array', () => {
|
||||
// arrange
|
||||
const inputArray = ['a', 'b', 'c', 'd'];
|
||||
// act
|
||||
const result = shuffle(inputArray);
|
||||
// assert
|
||||
expect(result).not.to.equal(inputArray);
|
||||
});
|
||||
|
||||
it('returns an array of the same length', () => {
|
||||
// arrange
|
||||
const inputArray = ['a', 'b', 'c', 'd'];
|
||||
// act
|
||||
const result = shuffle(inputArray);
|
||||
// assert
|
||||
expect(result.length).toBe(inputArray.length);
|
||||
});
|
||||
|
||||
it('contains the same elements', () => {
|
||||
// arrange
|
||||
const inputArray = ['a', 'b', 'c', 'd'];
|
||||
// act
|
||||
const result = shuffle(inputArray);
|
||||
// assert
|
||||
expect(result).to.have.members(inputArray);
|
||||
});
|
||||
|
||||
it('does not modify the input array', () => {
|
||||
// arrange
|
||||
const inputArray = ['a', 'b', 'c', 'd'];
|
||||
const inputArrayCopy = [...inputArray];
|
||||
// act
|
||||
shuffle(inputArray);
|
||||
// assert
|
||||
expect(inputArray).to.deep.equal(inputArrayCopy);
|
||||
});
|
||||
|
||||
it('handles an empty array correctly', () => {
|
||||
// arrange
|
||||
const inputArray: string[] = [];
|
||||
// act
|
||||
const result = shuffle(inputArray);
|
||||
// assert
|
||||
expect(result).have.lengthOf(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user