forked from malfynnction/AltText-Tweeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
87 lines (73 loc) · 2.76 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const test = require('ava')
const testTweets = require('./test-tweets.json')
const getReplyText = require('./get-reply-text')
const noAltText = "There is no alt text for this image, I'm sorry."
const video =
"This is a video. Unfortunately, twitter doesn't allow to add alt texts for videos yet."
test('classic flow, with alt text', async (t) => {
const reply = getReplyText(testTweets[1])
t.is(
await reply,
'@SnoringDoggo Athena the fluffy white and brown cat looks up innocently in front of a plush'
)
})
test('classic flow, no alt text', async (t) => {
const reply = getReplyText(testTweets[2])
t.is(await reply, `@solitaryrainbow ${noAltText}`)
})
test('triggering = original, no alt text', async (t) => {
const reply = getReplyText(testTweets[3])
t.is(await reply, `@womensart1 ${noAltText}`)
})
test('triggering = original, with alt text', async (t) => {
const reply = getReplyText(testTweets[4])
t.is(
await reply,
'@foxeen Winzige runde Tropfen entlang den fast unsichtbaren Fäden eines Spinnennetzes in Nahaufnahme - manche sind ganz scharf, manche unscharf, aber alle zusammen wirken wie feinste Perlen-Spitze, meisterlich geklöppelt.'
)
})
test('image in quote, alt text', async (t) => {
const reply = getReplyText(testTweets[5])
t.is(
await reply,
'@SehrysFlausch a tabby cat (@skyescats #OhMyOllie) sits on a chair, with its head looking up over a kitchen table. on the table is an unfinished jigsaw puzzle, the picture also featuring two tabby cats.'
)
})
test('image in quote, no alt text', async (t) => {
const reply = getReplyText(testTweets[6])
t.is(await reply, `@_cumasyouare_ ${noAltText}`)
})
test('no quote, no reply, no image', async (t) => {
const reply = getReplyText(testTweets[7])
t.is(await reply, undefined)
})
test('reply, but no image anywhere', async (t) => {
const reply = getReplyText(testTweets[8])
t.is(await reply, undefined)
})
test('quote, but no image anywhere', async (t) => {
const reply = getReplyText(testTweets[9])
t.is(await reply, undefined)
})
test('image in triggering as well as original', async (t) => {
const reply = getReplyText(testTweets[10])
t.is(
await reply,
'@malfynnction My new ID, stating that my first name is Fynn and my second name is Julius, everything else - except the photo - is blacked out'
)
})
test('tweet by bot itself', async (t) => {
const reply = getReplyText(testTweets[11])
t.is(await reply, undefined)
})
test('video', async (t) => {
const reply = getReplyText(testTweets[12])
t.is(await reply, `@souplemur ${video}`)
})
test('multiple images', async (t) => {
const reply = getReplyText(testTweets[13])
t.is(
await reply,
`@solitaryrainbow 1. Picture: ${noAltText}\n2. Picture: ${noAltText}\n3. Picture: ${noAltText}\n`
)
})