Skip to content

Commit 48274cc

Browse files
ittaibaratzmacdonst
authored andcommittedAug 15, 2019
Improve test coverage to 100% (#19)
* Add codecov support Add codecov support * Improve test coverage Improve test coverage
1 parent 7ffe5ed commit 48274cc

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
 

‎test/auth.test.js

+46
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,52 @@ describe('Fetch jwt', () => {
171171
).resolves.toEqual({ access_token: mockAccessToken, expires_in: 123456 });
172172
});
173173

174+
test('valid jwt, qualified scopes', () => {
175+
fetch.mockImplementation(() => mockResultSuccess);
176+
const metaScopes = [
177+
'https://ims-na1.adobelogin.com/s/ent_dataservices_sdk'
178+
];
179+
jwt.sign = jest.fn().mockImplementation(payload => {
180+
expect(payload[metaScopes[0]]).toBe(true);
181+
return 'my_jwt_token';
182+
});
183+
184+
return expect(
185+
auth({
186+
clientId,
187+
clientSecret,
188+
technicalAccountId,
189+
orgId,
190+
metaScopes,
191+
privateKey
192+
})
193+
).resolves.toEqual({ access_token: mockAccessToken, expires_in: 123456 });
194+
});
195+
196+
test('valid jwt, unqualified scopes', () => {
197+
fetch.mockImplementation(() => mockResultSuccess);
198+
const metaScopes = 'ent_dataservices_sdk,some_other_scope';
199+
jwt.sign = jest.fn().mockImplementation(payload => {
200+
expect(
201+
payload['https://ims-na1.adobelogin.com/s/ent_dataservices_sdk']
202+
).toBe(true);
203+
expect(payload['https://ims-na1.adobelogin.com/s/some_other_scope']).toBe(
204+
true
205+
);
206+
return 'my_jwt_token';
207+
});
208+
return expect(
209+
auth({
210+
clientId,
211+
clientSecret,
212+
technicalAccountId,
213+
orgId,
214+
metaScopes,
215+
privateKey
216+
})
217+
).resolves.toEqual({ access_token: mockAccessToken, expires_in: 123456 });
218+
});
219+
174220
test('invalid jwt, expected endpoint error', () => {
175221
expect.assertions(1);
176222
fetch.mockImplementation(() => mockResultFailure);

0 commit comments

Comments
 (0)
Please sign in to comment.