-
Notifications
You must be signed in to change notification settings - Fork 208
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
894b8dc
commit 89e847b
Showing
1 changed file
with
24 additions
and
10 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 |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import * as base64 from '../base64'; | ||
|
||
describe('helpers base64 url', function() { | ||
it('padding', function() { | ||
expect(base64.padding('')).toBe(''); | ||
expect(base64.padding('a')).toBe('a==='); | ||
expect(base64.padding('ab')).toBe('ab=='); | ||
expect(base64.padding('abc')).toBe('abc='); | ||
expect(base64.padding('abcd')).toBe('abcd'); | ||
expect(base64.padding('abced')).toBe('abced==='); | ||
expect(base64.padding(base64.padding('abc'))).toBe('abc='); | ||
describe('padding', function() { | ||
it('does not add to multiple of 4', function() { | ||
expect(base64.padding('')).toBe(''); | ||
expect(base64.padding('abcd')).toBe('abcd'); | ||
}); | ||
it('adds to non multiple of 4', function() { | ||
expect(base64.padding('a')).toBe('a==='); | ||
expect(base64.padding('ab')).toBe('ab=='); | ||
expect(base64.padding('abc')).toBe('abc='); | ||
expect(base64.padding('abced')).toBe('abced==='); | ||
}); | ||
it('does not change already padded value', function() { | ||
const padded = base64.padding('abc'); | ||
expect(padded).toBe('abc='); | ||
const again = base64.padding(padded); | ||
expect(again).toBe('abc='); | ||
}); | ||
}); | ||
|
||
it('decode to hex', function() { | ||
expect(base64.decodeToHEX('AQAB')).toBe('010001'); | ||
describe('decoding to hex', function() { | ||
it('should convert base64 input into hex output', function() { | ||
expect(base64.decodeToHEX('AQAB')).toBe('010001'); | ||
expect(base64.decodeToHEX('uGbXWiK3dQTyCbX5')).toBe( | ||
'b866d75a22b77504f209b5f9', | ||
); | ||
}); | ||
}); | ||
}); |