Skip to content

Commit

Permalink
Combine effects test files
Browse files Browse the repository at this point in the history
  • Loading branch information
bencodeorg committed Dec 14, 2023
1 parent c74a7ff commit e2343ce
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 69 deletions.
69 changes: 0 additions & 69 deletions test/unit/effects.js

This file was deleted.

68 changes: 68 additions & 0 deletions test/unit/effectsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const test = require('tape');
const sinon = require('sinon');
const utils = require('../../src/utils');
const helpers = require('../helpers/createDanceAPI');
const constants = require("../../src/constants");

test('setBackground clears the bgEffect and sets background_color', async t => {
const nativeAPI = await helpers.createDanceAPI();
Expand Down Expand Up @@ -202,3 +203,70 @@ test('logs invalid background palette', async t => {
nativeAPI.reset();
sinon.restore();
});


test('Set background effect to none, unknown, and known effects', async t => {
const nativeAPI = await helpers.createDanceAPI();
nativeAPI.play({
bpm: 120,
});

const spyNone = sinon.spy(nativeAPI.bgEffects_.none, 'draw');
const spyRainbow = sinon.spy(nativeAPI.bgEffects_.rainbow, 'draw');
const spyDisco = sinon.spy(nativeAPI.bgEffects_.disco, 'draw');

t.equal(spyNone.callCount, 0);
t.equal(spyRainbow.callCount, 0);
t.equal(spyDisco.callCount, 0);

nativeAPI.draw();

t.equal(spyNone.callCount, 1);
t.equal(spyRainbow.callCount, 0);
t.equal(spyDisco.callCount, 0);

nativeAPI.setBackgroundEffect('rainbow');
nativeAPI.draw();

t.equal(spyNone.callCount, 1);
t.equal(spyRainbow.callCount, 1);
t.equal(spyDisco.callCount, 0);

nativeAPI.setBackgroundEffect('disco');
nativeAPI.draw();

t.equal(spyNone.callCount, 1);
t.equal(spyRainbow.callCount, 1);
t.equal(spyDisco.callCount, 1);

nativeAPI.setBackground('blue');
nativeAPI.draw();

t.equal(spyNone.callCount, 2);
t.equal(spyRainbow.callCount, 1);
t.equal(spyDisco.callCount, 1);

nativeAPI.reset();
t.end();
});

test('All supported foreground effects exist', async t => {
const nativeAPI = await helpers.createDanceAPI();

const missingEffects = constants.FOREGROUND_EFFECTS.filter(effect => !nativeAPI.fgEffects_.hasOwnProperty(effect));
t.equal(missingEffects.length, 0);

nativeAPI.reset();
t.end();
});

test('All supported background effects exist', async t => {
const nativeAPI = await helpers.createDanceAPI();

const missingEffects = constants.BACKGROUND_EFFECTS.filter(effect => !nativeAPI.bgEffects_.hasOwnProperty(effect));
t.equal(missingEffects.length, 0);

nativeAPI.reset();
t.end();
});

0 comments on commit e2343ce

Please sign in to comment.