|
6 | 6 |
|
7 | 7 | import {expect} from 'chai'; |
8 | 8 | import sinon from 'sinon'; |
9 | | -import SandboxList from '../../../src/commands/sandbox/list.js'; |
| 9 | +import SandboxList, {COLUMNS} from '../../../src/commands/sandbox/list.js'; |
10 | 10 | import {isolateConfig, restoreConfig} from '@salesforce/b2c-tooling-sdk/test-utils'; |
11 | 11 | import {runSilent} from '../../helpers/test-setup.js'; |
12 | 12 |
|
@@ -97,6 +97,44 @@ describe('sandbox list', () => { |
97 | 97 | }); |
98 | 98 | }); |
99 | 99 |
|
| 100 | + describe('eol column formatting', () => { |
| 101 | + const getEol = COLUMNS.eol.get; |
| 102 | + |
| 103 | + it('returns "-" when eol is missing', () => { |
| 104 | + expect(getEol({} as any)).to.equal('-'); |
| 105 | + }); |
| 106 | + |
| 107 | + it('returns YYYY-MM-DD when EOL is more than 24 hours away', () => { |
| 108 | + const future = new Date(Date.now() + 48 * 60 * 60 * 1000).toISOString(); |
| 109 | + const result = getEol({eol: future} as any); |
| 110 | + expect(result).to.match(/^\d{4}-\d{2}-\d{2}$/); |
| 111 | + }); |
| 112 | + |
| 113 | + it('returns YYYY-MM-DD HH:mm when EOL is within 24 hours', () => { |
| 114 | + const soon = new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString(); |
| 115 | + const result = getEol({eol: soon} as any); |
| 116 | + expect(result).to.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/); |
| 117 | + }); |
| 118 | + |
| 119 | + it('returns YYYY-MM-DD HH:mm for an already-expired EOL', () => { |
| 120 | + const past = new Date(Date.now() - 60 * 60 * 1000).toISOString(); |
| 121 | + const result = getEol({eol: past} as any); |
| 122 | + expect(result).to.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/); |
| 123 | + }); |
| 124 | + |
| 125 | + it('returns correct UTC time in YYYY-MM-DD HH:mm format', () => { |
| 126 | + // Fixed timestamp: 2026-02-20T09:30:00Z — within 24h from now in the test |
| 127 | + const eolTime = new Date(Date.now() + 30 * 60 * 1000).toISOString(); // 30 minutes away |
| 128 | + const d = new Date(eolTime); |
| 129 | + const expectedDate = d.toISOString().slice(0, 10); |
| 130 | + const expectedHH = String(d.getUTCHours()).padStart(2, '0'); |
| 131 | + const expectedMM = String(d.getUTCMinutes()).padStart(2, '0'); |
| 132 | + |
| 133 | + const result = getEol({eol: eolTime} as any); |
| 134 | + expect(result).to.equal(`${expectedDate} ${expectedHH}:${expectedMM}`); |
| 135 | + }); |
| 136 | + }); |
| 137 | + |
100 | 138 | describe('filter parameter building', () => { |
101 | 139 | it('should build filter params from realm flag', () => { |
102 | 140 | const command = new SandboxList([], {} as any); |
|
0 commit comments