You can simulate the data within your program. Whether that’s inserting a test account with whatever necessary data (current timestamp or random name/id) before the original list or just calling the alert code with fake data.
Let’s say you have some way to get and return data.
function getAPI(endpoint, qs) {
return new Promise(/* ... */);
}
function getLastFollows(to_id) {
return getAPI('users/follows', { to_id });
}
You could create a separate temporary function or just add on to the original. You could even rename the original function slightly and reuse that name for the temp function.
function getLastFollowsFAKE(to_id) {
return getLastFollows(to_id)
.then(json => {
// Generate a random ID or a specific one that's not already following.
let from_id = Math.floor(Math.random() * 1e7 + 1e6).toString();
let followed_at = new Date().toISOString();
json.data.push({ from_id, to_id, followed_at });
return json;
});
}
However your system is set up to detect new follows, you will need to get the original data and then use the spoof function for a random user to trigger the alert.
Initialize real data
let channelID = '';
let seenList = [];
function init() {
getLastFollows(channelID)
.then(json => seenList = json.data.map(n => n.from_id))
.catch(handleError);
}
Get fake data when it’s time to check.
function update() {
getLastFollowsFAKE()
.then(json => {
let newFollows = json.data.filter(n => seenList.includes(n.from_id));
if(newFollows.length) {
newFollows.forEach(n => queueFollowAlert(n.from_id));
}
})
.catch(handleError);
}