Skip to content

Commit 0405de5

Browse files
committed
minor fix
1 parent b25d2ef commit 0405de5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/mastodonPost.spec.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,44 @@ import { test } from 'node:test'
77
import assert from 'node:assert'
88
import mastodonPost from '../lib/mastodonPost.ts'
99

10+
const defaultParams = {
11+
discount: 20,
12+
coupon: ':COUPON:',
13+
expiryDate: ':EXPIRATION:'
14+
};
15+
1016
test('Mastodon post should always include robot emoji', () => {
1117
for (let i = 0; i < 100; i++) {
12-
assert.ok(mastodonPost({ discount: 20, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).includes('[🤖]'))
18+
assert.ok(mastodonPost(defaultParams).includes('[🤖]'))
1319
}
1420
})
1521

1622
test('Mastodon post should always include #coupon hashtag', () => {
1723
for (let i = 0; i < 100; i++) {
18-
assert.ok(mastodonPost({ discount: 20, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).includes('#coupon'))
24+
assert.ok(mastodonPost(defaultParams).includes('#coupon'))
1925
}
2026
})
2127

2228
test('Mastodon post should always mention discount amount', () => {
2329
for (let i = 10; i < 40; i++) {
24-
assert.ok(mastodonPost({ discount: i, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).includes(i + '%'))
30+
assert.ok(mastodonPost(defaultParams).includes(i + '%'))
2531
}
2632
})
2733

2834
test('Mastodon post should always contain coupon code', () => {
2935
for (let i = 0; i < 100; i++) {
30-
assert.ok(mastodonPost({ discount: 20, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).includes(':COUPON:'))
36+
assert.ok(mastodonPost(defaultParams).includes(':COUPON:'))
3137
}
3238
})
3339

3440
test('Mastodon post should always mention expiration date', () => {
3541
for (let i = 0; i < 100; i++) {
36-
assert.ok(mastodonPost({ discount: 20, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).includes(':EXPIRATION:'))
42+
assert.ok(mastodonPost(defaultParams).includes(':EXPIRATION:'))
3743
}
3844
})
3945

4046
test('Mastodon post should never be longer than 500 characters', () => {
4147
for (let i = 0; i < 100; i++) {
42-
assert.ok(mastodonPost({ discount: 20, coupon: ':COUPON:', expiryDate: ':EXPIRATION:' }).length <= 500)
48+
assert.ok(mastodonPost(defaultParams).length <= 500)
4349
}
4450
})

0 commit comments

Comments
 (0)