mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-02 22:17:18 +01:00
add jest
This commit is contained in:
17
jest.config.js
Normal file
17
jest.config.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
module.exports = {
|
||||||
|
roots: ['<rootDir>'],
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
|
||||||
|
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'],
|
||||||
|
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.(ts|tsx)$': 'babel-jest',
|
||||||
|
},
|
||||||
|
watchPlugins: [
|
||||||
|
'jest-watch-typeahead/filename',
|
||||||
|
'jest-watch-typeahead/testname',
|
||||||
|
],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
|
||||||
|
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__mocks__/fileMock.js',
|
||||||
|
},
|
||||||
|
}
|
||||||
28
lib/id.test.ts
Normal file
28
lib/id.test.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { getId } from './id'
|
||||||
|
|
||||||
|
const defaultDoc = {
|
||||||
|
address: 'Max Mustermann\nMusterstrasse\n12345 Musterstadt',
|
||||||
|
body: 'Inhalt des Briefs',
|
||||||
|
closing: 'Mit freundlichen Grüßen',
|
||||||
|
customer: '',
|
||||||
|
date: new Date('2021-01-01').toLocaleDateString('de-DE'),
|
||||||
|
enclosing: '',
|
||||||
|
invoice: '',
|
||||||
|
myRef: '',
|
||||||
|
opening: 'Sehr geehrte Damen und Herren',
|
||||||
|
ps: '',
|
||||||
|
signature: '',
|
||||||
|
specialMail: '',
|
||||||
|
subject: 'Betreffzeile',
|
||||||
|
letterOption: 'brief-fam',
|
||||||
|
yourMail: '',
|
||||||
|
yourRef: '',
|
||||||
|
yourRefName: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('getId', () => {
|
||||||
|
it('generates id for default doc', () => {
|
||||||
|
const id = getId(defaultDoc)
|
||||||
|
expect(id).toEqual('836fbb708bb6807db39ba06332b559d44063e8ba')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user