Skip to content

Instantly share code, notes, and snippets.

View Fazendaaa's full-sized avatar

Lucas de Almeida Carotta Fazendaaa

View GitHub Profile
node_modules
coverage
.env
PASS __tests__/main.test.ts
Testando a função mascararDados.
✓ Verificando input vs output da pesquisa de Nerdcast. (2ms)
Testando a função mascararDadosInline.
✓ Verificando input vs output da pesquisa de Nerdcast.
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 28.26 | 0 | 0 | 28.26 | |
{
"compilerOptions": {
...
"typeRoots": [
"node_modules",
"jest"
],
"types": [
"node",
"jest"
/**
* Testes.
*/
'use strict';
import { readFile } from 'fs';
import { join } from 'path';
import {
mascararDados,
mascararDadosInline
@Fazendaaa
Fazendaaa / inputCmd.json
Last active March 27, 2018 03:34
__mocksData__
{
"wrapperType": "track",
"kind": "podcast",
"collectionId": 1103141552,
"trackId": 1103141552,
"artistName": "Nerdcast",
"collectionName": "Nerdcast",
"trackName": "Nerdcast",
"collectionCensoredName": "Nerdcast",
"trackCensoredName": "Nerdcast",
module.exports = {
globals: {
'ts-jest': {
enableTsDiagnostics: true,
},
},
verbose: true,
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
{
...
"scripts": {
"test": "jest --config jest.config.js --ci --forceExit"
...
},
...
}
npm install jest ts-jest @types/jest request --save-dev
bot.on('inline_query', ({ answerInlineQuery, inlineQuery }) => {
const nome: string = inlineQuery.query;
// Quantidade máxima de podcasts a serem pequisados para serem retornados por pesquisa.
const limitePesquisa: number = 20;
// Offset é a "página" que o usário se encontra no scroll das pequisas inline.
const offset: number = parseInt(inlineQuery.offset, 10) || 0;
const opcoes: object = {
media: 'podcast',
entity: 'podcast',
limit: offset + limitePesquisa
bot.command('search', ({ replyWithMarkdown, message }) => {
// Irá remover o '/search' da pequisa e retornar apenas o nome da podcast.
const nome: string = message.text.replace(/(\/\w+)\s*/, '');
// Parametros para a pesquisa na iTunes, aqui que você deve mudar caso queira fazer deste um bot de música ou de filmes.
const opcoes: object = {
media: 'podcast',
entity: 'podcast',
limit: 1
};