-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b883805
commit ba7e913
Showing
1 changed file
with
0 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
}) */ | ||
}) |