2019-06-03 03:49:05 -05:00
|
|
|
import * as ttlHandler from '../src/app/ttl-handler';
|
|
|
|
|
|
|
|
describe('ttl handler', () => {
|
2021-01-29 00:25:40 -06:00
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetModules();
|
|
|
|
});
|
2019-06-03 03:49:05 -05:00
|
|
|
|
2021-01-29 00:25:40 -06:00
|
|
|
it('should return -1 for getExpiryTime', () => {
|
|
|
|
expect(ttlHandler.getExpiryTime()).toBeDefined();
|
|
|
|
});
|
2019-06-03 03:49:05 -05:00
|
|
|
|
2021-01-29 00:25:40 -06:00
|
|
|
it('should return true if build is expired', () => {
|
|
|
|
const expiryMock = jest.spyOn(ttlHandler, 'getExpiryTime');
|
|
|
|
expiryMock.mockImplementation(() => Date.now() - 10 * 24 * 60);
|
|
|
|
expect(ttlHandler.checkIfBuildExpired()).toBeTruthy();
|
|
|
|
});
|
2019-06-03 03:49:05 -05:00
|
|
|
|
2021-01-29 00:25:40 -06:00
|
|
|
it('should return false if build is valid', () => {
|
|
|
|
const expiryMock = jest.spyOn(ttlHandler, 'getExpiryTime');
|
|
|
|
expiryMock.mockImplementation(() => Date.now() + 10 * 24 * 60);
|
|
|
|
expect(ttlHandler.checkIfBuildExpired()).toBeFalsy();
|
|
|
|
});
|
2019-06-03 03:49:05 -05:00
|
|
|
|
2021-01-29 00:25:40 -06:00
|
|
|
it('should return false if ttl is not applicable', () => {
|
|
|
|
const expiryMock = jest.spyOn(ttlHandler, 'getExpiryTime');
|
|
|
|
expiryMock.mockImplementation(() => -1);
|
|
|
|
expect(ttlHandler.checkIfBuildExpired()).toBeFalsy();
|
|
|
|
});
|
2019-06-03 03:49:05 -05:00
|
|
|
});
|