exhaustive tests for sequencer function
All checks were successful
Unit tests / Unit tests (push) Successful in -2m10s
NPM Audit Check / Check NPM audit (push) Successful in -2m17s

This commit is contained in:
2025-08-29 11:11:16 -05:00
parent e6964315ab
commit 0c3b5c3be5
3 changed files with 101 additions and 15 deletions

View File

@@ -9,7 +9,7 @@ vi.mock('openweather-api-node', () => {
return {
OpenWeatherAPI: vi.fn().mockImplementation((_) => {
return {
getCurrent: vi.fn(() => {
getToday: vi.fn(() => {
return {
"lat": 43.0748,
"lon": -89.3838,
@@ -106,5 +106,85 @@ describe('sequencer', () => {
weather: dummyWeather
})).to.be.ordered.members(['seq1.flac', 'seq1.flac']);
});
it('throws an error on invalid conditions', async () => {
await expect(Sequencer({
programs: [['sequence 1']],
segments: {
},
sequences: {
'sequence 1': {
'conditions': ['100'],
'tracks': [
'seq1.flac'
]
}
},
voices: {},
weather: dummyWeather
})).rejects.toThrow(/not in the correct format/);
await expect(Sequencer({
programs: [['sequence 1']],
segments: {
},
sequences: {
'sequence 1': {
'conditions': ['1 ~ 2'],
'tracks': [
'seq1.flac'
]
}
},
voices: {},
weather: dummyWeather
})).rejects.toThrow(/Unsupported relational operator/);
});
it('can stringify conditions', async () => {
expect(await Sequencer({
programs: [['sequence 1']],
segments: {
},
sequences: {
'sequence 1': {
'conditions': ['weather.feelsLike = {"cur":55.31}'],
'tracks': [
'seq1.flac'
]
}
},
voices: {},
weather: dummyWeather
})).to.be.ordered.members(['seq1.flac']);
});
it('can parse voice macros', async () => {
expect(await Sequencer({
programs: [['sequence 1']],
segments: {
},
sequences: {
'sequence 1': {
'tracks': [
'%alice weather.temp.max'
]
}
},
voices: {
"alice": {
"directory": "alice/",
"extension": "flac"
}
},
weather: dummyWeather
})).to.be.ordered.members([
'alice/fifty.flac',
'alice/eight.flac',
'alice/point.flac',
'alice/zero.flac',
'alice/one.flac'
]);
});
});