Skip to content

Commit

Permalink
tests: remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Oct 2, 2024
1 parent b883805 commit ba7e913
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions src/commands/login/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,59 +217,4 @@ describe('loginCommand', () => {
expect(errorArg.message).toBe(expectedMessage)
})
})

/* it('should login with token when token is provided', async () => {
const mockToken = 'test-token'
const mockUser = { email: '[email protected]' }
loginWithToken.mockResolvedValue({ user: mockUser })
await loginCommand.parseAsync(['node', 'test', '--token', mockToken])
expect(loginWithToken).toHaveBeenCalledWith(mockToken, 'eu')
expect(addNetrcEntry).toHaveBeenCalledWith({
machineName: 'api.storyblok.com',
login: mockUser.email,
password: mockToken,
region: 'eu',
})
expect(konsola.ok).toHaveBeenCalledWith('Successfully logged in with token')
})
it('should prompt for login strategy when no token is provided', async () => {
select.mockResolvedValueOnce('login-with-token')
password.mockResolvedValueOnce('test-token')
const mockUser = { email: '[email protected]' }
loginWithToken.mockResolvedValue({ user: mockUser })
await loginCommand.parseAsync(['node', 'test'])
expect(select).toHaveBeenCalledWith(expect.objectContaining({
message: 'How would you like to login?',
}))
expect(password).toHaveBeenCalledWith(expect.objectContaining({
message: 'Please enter your token:',
}))
expect(loginWithToken).toHaveBeenCalledWith('test-token', 'eu')
expect(addNetrcEntry).toHaveBeenCalledWith({
machineName: 'api.storyblok.com',
login: mockUser.email,
password: 'test-token',
region: 'eu',
})
expect(konsola.ok).toHaveBeenCalledWith('Successfully logged in with token')
})
it('should handle invalid region error with correct message', async () => {
await loginCommand.parseAsync(['node', 'test', '--region', 'invalid-region'])
expect(konsola.error).toHaveBeenCalledWith(expect.any(Error), true)
// Access the error argument
const errorArg = konsola.error.mock.calls[0][0]
// Build the expected error message
const expectedMessage = `The provided region: invalid-region is not valid. Please use one of the following values: ${Object.values(regions).join(' | ')}`
expect(errorArg.message).toBe(expectedMessage)
}) */
})

0 comments on commit ba7e913

Please sign in to comment.