This commit is contained in:
Thomas Ruoff
2021-03-10 23:54:14 +01:00
parent 1633fad10b
commit f95c2a18a9
2 changed files with 45 additions and 0 deletions

17
jest.config.js Normal file
View 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
View 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')
})
})