-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
1 changed file
with
44 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { parseIfNoneMatchHeader } from '../cache'; | ||
|
||
describe('cache', () => { | ||
test('parse if-none-match header', () => { | ||
// Test various combinations of etags with and without weak-validation prefix, with and without | ||
// wrapping quotes, without and without spaces after commas. | ||
const vectors: { | ||
input: string | undefined; | ||
output: string[] | undefined; | ||
}[] = [ | ||
{ input: '""', output: undefined }, | ||
{ input: '', output: undefined }, | ||
{ input: undefined, output: undefined }, | ||
{ | ||
input: '"bfc13a64729c4290ef5b2c2730249c88ca92d82d"', | ||
output: ['bfc13a64729c4290ef5b2c2730249c88ca92d82d'], | ||
}, | ||
{ input: 'W/"67ab43", "54ed21", "7892dd"', output: ['67ab43', '54ed21', '7892dd'] }, | ||
{ input: '"fail space" ', output: ['fail space'] }, | ||
{ input: 'W/"5e15153d-120f"', output: ['5e15153d-120f'] }, | ||
{ | ||
input: '"<etag_value>", "<etag_value>" , "asdf"', | ||
output: ['<etag_value>', '<etag_value>', 'asdf'], | ||
}, | ||
{ | ||
input: '"<etag_value>","<etag_value>","asdf"', | ||
output: ['<etag_value>', '<etag_value>', 'asdf'], | ||
}, | ||
{ | ||
input: 'W/"<etag_value>","<etag_value>","asdf"', | ||
output: ['<etag_value>', '<etag_value>', 'asdf'], | ||
}, | ||
{ | ||
input: '"<etag_value>",W/"<etag_value>", W/"asdf", "abcd","123"', | ||
output: ['<etag_value>', '<etag_value>', 'asdf', 'abcd', '123'], | ||
}, | ||
]; | ||
expect(vectors).toBeTruthy(); | ||
for (const entry of vectors) { | ||
const result = parseIfNoneMatchHeader(entry.input); | ||
expect(result).toEqual(entry.output); | ||
} | ||
}); | ||
}); |