forked from prisma/prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printUpdateMessage.test.ts
55 lines (50 loc) · 2.57 KB
/
printUpdateMessage.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { printUpdateMessage } from '../utils/printUpdateMessage'
function printUpdateMessageFromTo(from: string, to: string): void {
printUpdateMessage({
status: 'ok',
data: {
client_event_id: '',
previous_client_event_id: '',
product: '',
cli_path_hash: '',
local_timestamp: '',
previous_version: from,
current_version: to,
current_release_date: Date.now(),
current_download_url: '',
current_changelog_url: '',
package: 'prisma',
release_tag: to,
install_command: '',
project_website: '',
outdated: true,
alerts: [],
},
})
}
const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation()
afterEach(() => {
consoleErrorMock.mockReset()
})
test('normal release', () => {
printUpdateMessageFromTo('4.5.0', '4.6.0')
expect(consoleErrorMock.mock.calls[0][0]).toMatchInlineSnapshot(`
"┌─────────────────────────────────────────────────────────┐
│ Update available 4.5.0 -> 4.6.0 │
│ Run the following to update │
│ npm i --save-dev [email protected] │
│ npm i @prisma/[email protected] │
└─────────────────────────────────────────────────────────┘"
`)
})
test('integration version with long name', () => {
printUpdateMessageFromTo('4.5.0-integration-use-keep-alive-for-node-fetch.1', '4.6.0')
expect(consoleErrorMock.mock.calls[0][0]).toMatchInlineSnapshot(`
"┌───────────────────────────────────────────────────────────────────────────────┐
│ Update available 4.5.0-integration-use-keep-alive-for-node-fetch.1 -> 4.6.0 │
│ Run the following to update │
│ npm i --save-dev [email protected] │
│ npm i @prisma/[email protected] │
└───────────────────────────────────────────────────────────────────────────────┘"
`)
})