Skip to content

Commit d318b64

Browse files
committed
Test getByUsername unhappy path
1 parent 6cf7611 commit d318b64

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/index.test.js

+13
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,19 @@ test('should get user by username', async () => {
688688
expect(got.mock.calls[0]).toMatchSnapshot();
689689
});
690690

691+
test('should get user by username fail when api fails', async () => {
692+
const api = new SauceLabs({user: 'foo', key: 'bar'});
693+
got.mockReturnValue(Promise.reject(new Error('example')));
694+
const error = await api
695+
.getUserByUsername({username: 'fooUser'})
696+
.catch((err) => err);
697+
expect(error).toEqual(
698+
new Error(
699+
'There was an error while fetching user information: Failed calling getUsersV1: example, undefined'
700+
)
701+
);
702+
});
703+
691704
test('should get list of builds', async () => {
692705
const api = new SauceLabs({user: 'foo', key: 'bar'});
693706
got

0 commit comments

Comments
 (0)