@@ -7,38 +7,44 @@ import { test } from 'node:test'
7
7
import assert from 'node:assert'
8
8
import mastodonPost from '../lib/mastodonPost.ts'
9
9
10
+ const defaultParams = {
11
+ discount : 20 ,
12
+ coupon : ':COUPON:' ,
13
+ expiryDate : ':EXPIRATION:'
14
+ } ;
15
+
10
16
test ( 'Mastodon post should always include robot emoji' , ( ) => {
11
17
for ( let i = 0 ; i < 100 ; i ++ ) {
12
- assert . ok ( mastodonPost ( { discount : 20 , coupon : ':COUPON:' , expiryDate : ':EXPIRATION:' } ) . includes ( '[🤖]' ) )
18
+ assert . ok ( mastodonPost ( defaultParams ) . includes ( '[🤖]' ) )
13
19
}
14
20
} )
15
21
16
22
test ( 'Mastodon post should always include #coupon hashtag' , ( ) => {
17
23
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' ) )
19
25
}
20
26
} )
21
27
22
28
test ( 'Mastodon post should always mention discount amount' , ( ) => {
23
29
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 + '%' ) )
25
31
}
26
32
} )
27
33
28
34
test ( 'Mastodon post should always contain coupon code' , ( ) => {
29
35
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:' ) )
31
37
}
32
38
} )
33
39
34
40
test ( 'Mastodon post should always mention expiration date' , ( ) => {
35
41
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:' ) )
37
43
}
38
44
} )
39
45
40
46
test ( 'Mastodon post should never be longer than 500 characters' , ( ) => {
41
47
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 )
43
49
}
44
50
} )
0 commit comments