Skip to content

Commit

Permalink
refactor(tests): add spaces between given/when/then
Browse files Browse the repository at this point in the history
  • Loading branch information
barroro committed Feb 14, 2025
1 parent cc24fe1 commit ab14005
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/clients/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,30 @@ describe('AuthClient', () => {
vi.spyOn(authClient, 'getToken');
vi.spyOn(authClient, 'getHeaderName');
const client = new BaseHTTPAuthHeaderBuilder(authClient);

const token = 'app-token';
await client.buildHeader(token);

expect(authClient.getToken).toHaveBeenCalled();
expect(authClient.getHeaderName).toHaveBeenCalled();
});

it('should return the correct auth header if token is provided', async () => {
const client = new BaseHTTPAuthHeaderBuilder();

const token = 'app-token';
const headers = await client.buildHeader(token);

expect(headers).toEqual({ Authorization: 'Bearer app-token' });
});

it('should return the correct auth header if authClient and token are provided', async () => {
const authClient = createAuthClient();
const client = new BaseHTTPAuthHeaderBuilder(authClient);

const token = 'app-token';
const headers = await client.buildHeader(token);

expect(headers).toEqual({
Authorization: 'Bearer app-token',
'X-Serverless-Authorization': 'Bearer test-token',
Expand All @@ -93,6 +99,7 @@ describe('AuthClient', () => {
const authClient = createAuthClient();
authClient.setGetTokenErrorMessage(errorMessage);
const client = new BaseHTTPAuthHeaderBuilder(authClient);

const token = 'app-token';
await expect(client.buildHeader(token)).rejects.toThrow(errorMessage);
});
Expand Down

0 comments on commit ab14005

Please sign in to comment.