diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/container_registry/explorer/utils_spec.js')
-rw-r--r-- | spec/frontend/packages_and_registries/container_registry/explorer/utils_spec.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/utils_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/utils_spec.js new file mode 100644 index 00000000000..5063759a620 --- /dev/null +++ b/spec/frontend/packages_and_registries/container_registry/explorer/utils_spec.js @@ -0,0 +1,21 @@ +import { timeTilRun } from '~/packages_and_registries/container_registry/explorer/utils'; + +describe('Container registry utilities', () => { + describe('timeTilRun', () => { + beforeEach(() => { + jest.spyOn(Date, 'now').mockImplementation(() => new Date('2063-04-04T00:42:00Z').getTime()); + }); + + it('should return a human readable time', () => { + const result = timeTilRun('2063-04-08T01:44:03Z'); + + expect(result).toBe('4 days'); + }); + + it('should return an empty string with null times', () => { + const result = timeTilRun(null); + + expect(result).toBe(''); + }); + }); +}); |