Add tests to action
All checks were successful
ci / build-image (push) Successful in 59s
ci / test-image (push) Successful in 8s

This commit is contained in:
Jonathan Cremin 2025-06-12 18:18:57 +01:00
parent 91d9af097d
commit 4dfd6e93b2
8 changed files with 139 additions and 48 deletions

View file

@ -1,40 +1,63 @@
import 'should';
import * as spotify from '../../lib/services/spotify/index.js';
import "should";
import * as spotify from "../../lib/services/spotify/index.js";
describe('Spotify', function(){
describe('lookupId', function(){
it('should find album by ID', async function (){
const result = await spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album');
result.name.should.equal('Listen');
});
it('should find track by ID', async function (){
const result = await spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track');
result.name.should.equal('Take Me To Church');
describe("Spotify", function() {
describe("init", function() {
it("should have secrets", async function() {
process.env.SPOTIFY_CLIENT_ID.should.exist;
});
});
describe('search', function(){
it('should find album by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
result.name.should.equal('Listen (Deluxe)');
describe("lookupId", function() {
it("should find album by ID", async function() {
const result = await spotify.lookupId("77UW17CZFyCaRLHdHeofZu", "album");
result.name.should.equal("Listen");
});
it('should find br album by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'});
result.name.should.equal('Fica');
});
it('should find album by various artists by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Get Down Part II: Original Soundtrack From The Netflix Original Series'});
result.name.should.equal('The Get Down Part II: Original Soundtrack From The Netflix Original Series');
it("should find track by ID", async function() {
const result = await spotify.lookupId("7dS5EaCoMnN7DzlpT6aRn2", "track");
result.name.should.equal("Take Me To Church");
});
});
describe('parseUrl', function(){
it('should parse url into ID', async function (){
const result = await spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu');
result.id.should.equal('77UW17CZFyCaRLHdHeofZu');
describe("search", function() {
it("should find album by search", async function() {
const result = await spotify.search({
type: "album",
artist: { name: "David Guetta" },
name: "Listen (Deluxe)"
});
result.name.should.equal("Listen (Deluxe)");
});
it("should find br album by search", async function() {
const result = await spotify.search({
type: "album",
artist: { name: "Anavitória" },
name: "Fica"
});
result.name.should.equal("Fica");
});
it("should find album by various artists by search", async function() {
const result = await spotify.search({
type: "album",
artist: { name: "Various Artists" },
name:
"The Get Down Part II: Original Soundtrack From The Netflix Original Series"
});
result.name.should.equal(
"The Get Down Part II: Original Soundtrack From The Netflix Original Series"
);
});
});
describe("parseUrl", function() {
it("should parse url into ID", async function() {
const result = await spotify.parseUrl(
"https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu"
);
result.id.should.equal("77UW17CZFyCaRLHdHeofZu");
});
});
});

View file

@ -0,0 +1,46 @@
import 'should';
import * as spotify from '../../lib/services/spotify/index.js';
describe('Spotify', function(){
describe('init', function(){
it('should have secrets', async function (){
process.env.SPOTIFY_CLIENT_ID.should.exist();
});
});
describe('lookupId', function(){
it('should find album by ID', async function (){
const result = await spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album');
result.name.should.equal('Listen');
});
it('should find track by ID', async function (){
const result = await spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track');
result.name.should.equal('Take Me To Church');
});
});
describe('search', function(){
it('should find album by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
result.name.should.equal('Listen (Deluxe)');
});
it('should find br album by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'});
result.name.should.equal('Fica');
});
it('should find album by various artists by search', async function (){
const result = await spotify.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Get Down Part II: Original Soundtrack From The Netflix Original Series'});
result.name.should.equal('The Get Down Part II: Original Soundtrack From The Netflix Original Series');
});
});
describe('parseUrl', function(){
it('should parse url into ID', async function (){
const result = await spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu');
result.id.should.equal('77UW17CZFyCaRLHdHeofZu');
});
});
});

View file

@ -1,18 +1,23 @@
import 'should';
import * as youtube from '../../lib/services/youtube/index.js';
import "should";
import * as youtube from "../../lib/services/youtube/index.js";
describe('Youtube', function(){
describe('lookup', function(){
it('should find album by lookup', async function (){
const result = await youtube.lookupId('6JnGBs88sL0');
result.name.should.equal('Say It Right');
describe("Youtube", function() {
describe("lookup", function() {
it("should find album by lookup", async function() {
const result = await youtube.lookupId("6JnGBs88sL0");
result.name.should.equal("Say It Right");
});
});
describe('search', function(){
it('should find album by search', async function (){
const result = await youtube.search({type: 'track', artist: {name: 'Aesop Rock'}, album: {name: 'Skeconsthon'}, name: 'Zero Dark Thirty'});
result.name.should.equal('Aesop Rock - Zero Dark Thirty (Official Video)');
describe("search", function() {
it("should find album by search", async function() {
const result = await youtube.search({
type: "track",
artist: { name: "Aesop Rock" },
album: { name: "Skeconsthon" },
name: "Zero Dark Thirty"
});
result.name.should.startWith("Aesop Rock - Zero Dark Thirty");
});
});
});