-
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
8 changed files
with
267 additions
and
35 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 Pipeline scheduled time', () => { | ||
expect(replaceNumericPartWithString('123Hour', 43424)).toBe('43424Hour'); | ||
}); | ||
|
||
it('should handle default Pipeline scheduled time', () => { | ||
expect(replaceNumericPartWithString('1Week', 26)).toBe('26Week'); | ||
}); | ||
}); | ||
|
||
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'); | ||
}); | ||
|
||
it('should handle Pipeline scheduled time', () => { | ||
expect(replaceNonNumericPartWithString('123Week', 'Minute')).toBe('123Minute'); | ||
}); | ||
|
||
it('should handle default Pipeline scheduled time', () => { | ||
expect(replaceNonNumericPartWithString('1Week', 'Minute')).toBe('1Minute'); | ||
}); | ||
}); |
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,41 @@ | ||
import { convertPeriodicTimeToSeconds, convertSecondsToPeriodicTime } from '~/utilities/time'; | ||
|
||
describe('Convert periodic time to seconds', () => { | ||
it('should convert hours to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('5Hour')).toBe(5 * 60 * 60); | ||
}); | ||
|
||
it('should convert minutes to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('6Minute')).toBe(6 * 60); | ||
}); | ||
|
||
it('should convert days to seconds', () => { | ||
expect(convertPeriodicTimeToSeconds('221Day')).toBe(221 * 24 * 60 * 60); | ||
}); | ||
|
||
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); | ||
}); | ||
}); | ||
|
||
describe('Convert seconds to periodic time', () => { | ||
it('should convert seconds to minutes', () => { | ||
expect(convertSecondsToPeriodicTime(120)).toBe('2Minute'); | ||
}); | ||
|
||
it('should convert seconds to hours', () => { | ||
expect(convertSecondsToPeriodicTime(7200)).toBe('2Hour'); | ||
}); | ||
|
||
it('should convert seconds to days', () => { | ||
expect(convertSecondsToPeriodicTime(172800)).toBe('2Day'); | ||
}); | ||
|
||
it('should convert seconds to weeks', () => { | ||
expect(convertSecondsToPeriodicTime(604800)).toBe('1Week'); | ||
}); | ||
}); |
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
Oops, something went wrong.