Skip to content

Commit

Permalink
test: added one simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Dec 27, 2021
1 parent abd4e8b commit fec63a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/ArthurFiorette/prettier-config

module.exports = require('@arthurfiorette/prettier-config')({
tsdoc: true,
plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-jsdoc']
tsdoc: true
//plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-jsdoc']
});
2 changes: 1 addition & 1 deletion src/header/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const interpretCacheControl: HeaderInterpreter = (cacheControl, headers) => {
return maxAge * 1000;
}

return maxAge * 1000 - Number(age) * 1000;
return (maxAge - Number(age)) * 1000;
}

return undefined;
Expand Down
10 changes: 6 additions & 4 deletions test/header/interpreter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { Header } from '../../src/util/headers';

describe('tests header interpreter', () => {
it('tests without cache-control header', () => {
const noHeader = defaultHeaderInterpreter();
expect(noHeader).toBeUndefined();
expect(defaultHeaderInterpreter()).toBeUndefined();

const emptyHeader = defaultHeaderInterpreter({ [Header.CacheControl]: '' });
expect(emptyHeader).toBeUndefined();
expect(defaultHeaderInterpreter({})).toBeUndefined();

expect(defaultHeaderInterpreter({ [Header.CacheControl]: '' })).toBeUndefined();

expect(defaultHeaderInterpreter({ ['x-random-header']: '' })).toBeUndefined();
});

it('tests with cache preventing headers', () => {
Expand Down

0 comments on commit fec63a8

Please sign in to comment.