Skip to content

Commit 168e67b

Browse files
committed
test: basic tests
1 parent e4b487a commit 168e67b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/content.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Content } from '../src'
2+
3+
describe('Content', () => {
4+
it('should serialize to JSON correctly', () => {
5+
const content = Content.builder().text('Hello world').build()
6+
const expectedContent = JSON.stringify({
7+
version: 0,
8+
theme: 'UNSTYLED',
9+
header: [],
10+
body: [
11+
[
12+
{
13+
id: 'TEXT',
14+
text: 'Hello world',
15+
},
16+
],
17+
],
18+
footer: [],
19+
})
20+
21+
expect(JSON.stringify(content)).toEqual(expectedContent)
22+
})
23+
})

tests/emailAddress.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { EmailAddress } from '../src'
2+
3+
describe('EmailAddress', () => {
4+
it('should serialize to JSON correctly with a name', () => {
5+
const email = new EmailAddress('[email protected]', 'John Doe')
6+
const expectedJson = JSON.stringify({
7+
8+
name: 'John Doe',
9+
})
10+
11+
expect(JSON.stringify(email)).toEqual(expectedJson)
12+
})
13+
14+
it('should serialize to JSON correctly without a name', () => {
15+
const email = new EmailAddress('[email protected]')
16+
const expectedJson = JSON.stringify({
17+
18+
name: null,
19+
})
20+
21+
expect(JSON.stringify(email)).toEqual(expectedJson)
22+
})
23+
})

0 commit comments

Comments
 (0)