-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a numerical input to Create Periodic Scheduled Runs
- Loading branch information
Showing
6 changed files
with
212 additions
and
15 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,61 @@ | ||
import { replaceNonNumericPartWithString, replaceNumericPartWithString } from '~/utilities/string'; | ||
|
||
describe('replaceNumericPartWithString', () => { | ||
it('should replace the numeric part of a string with a number', () => { | ||
expect(replaceNumericPartWithString('abc123xyz', 456)).toBe('abc456xyz'); | ||
}); | ||
|
||
it('should handle empty input string', () => { | ||
expect(replaceNumericPartWithString('', 789)).toBe('789'); | ||
}); | ||
|
||
it('should handle input string without numeric part', () => { | ||
expect(replaceNumericPartWithString('abcdef', 123)).toBe('123abcdef'); | ||
}); | ||
|
||
it('should handle numeric part at the beginning of the string', () => { | ||
expect(replaceNumericPartWithString('123xyz', 789)).toBe('789xyz'); | ||
}); | ||
|
||
it('should handle numeric part at the end of the string', () => { | ||
expect(replaceNumericPartWithString('abc456', 123)).toBe('abc123'); | ||
}); | ||
|
||
it('should handle zero numeric replacement', () => { | ||
expect(replaceNumericPartWithString('abc0xyz', 123)).toBe('abc123xyz'); | ||
}); | ||
}); | ||
|
||
describe('replaceNonNumericPartWithString', () => { | ||
it('should replace the non-numeric part of a string with another string', () => { | ||
expect(replaceNonNumericPartWithString('abc123xyz', 'XYZ')).toBe('XYZ123xyz'); | ||
}); | ||
|
||
it('should handle empty input string', () => { | ||
expect(replaceNonNumericPartWithString('', 'XYZ')).toBe('XYZ'); | ||
}); | ||
|
||
it('should handle input string with no non-numeric part', () => { | ||
expect(replaceNonNumericPartWithString('123', 'XYZ')).toBe('123XYZ'); | ||
}); | ||
|
||
it('should handle input string with only non-numeric part', () => { | ||
expect(replaceNonNumericPartWithString('abc', 'XYZ')).toBe('XYZ'); | ||
}); | ||
|
||
it('should handle input string with multiple non-numeric parts', () => { | ||
expect(replaceNonNumericPartWithString('abc123def456', 'XYZ')).toBe('XYZ123def456'); | ||
}); | ||
|
||
it('should handle replacement string containing numbers', () => { | ||
expect(replaceNonNumericPartWithString('abc123xyz', '123')).toBe('123123xyz'); | ||
}); | ||
|
||
it('should handle replacement string containing special characters', () => { | ||
expect(replaceNonNumericPartWithString('abc123xyz', '@#$')).toBe('@#$123xyz'); | ||
}); | ||
|
||
it('should handle replacement string containing spaces', () => { | ||
expect(replaceNonNumericPartWithString('abc123xyz', ' ')).toBe(' 123xyz'); | ||
}); | ||
}); |
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,27 @@ | ||
import { convertPeriodicTimeToSeconds } from '~/utilities/time'; | ||
|
||
describe('Convert periodic time to seconds', () => { | ||
it('should convert hours to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('5Hour')).toBe(5 * 3600); | ||
}); | ||
|
||
it('should convert minutes to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('6Minute')).toBe(6 * 60); | ||
}); | ||
|
||
it('should convert days to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('221Day')).toBe(221 * 86400); | ||
}); | ||
|
||
it('should convert weeks to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('12Week')).toBe(12 * 7 * 24 * 60 * 60); | ||
}); | ||
|
||
it('should default to 0 seconds for unrecognized units', () => { | ||
expect(convertPeriodicTimeToSeconds('3Weeks')).toBe(0); | ||
}); | ||
|
||
it('should default to 0 seconds for NaN', () => { | ||
expect(convertPeriodicTimeToSeconds('hour12')).toBe(0); | ||
}); | ||
}); |
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
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