diff --git a/fixtures/anchorPlaysByGenderEmpty.json b/fixtures/anchorPlaysByGenderEmpty.json new file mode 100644 index 0000000..1536570 --- /dev/null +++ b/fixtures/anchorPlaysByGenderEmpty.json @@ -0,0 +1,35 @@ +{ + "provider": "anchor", + "version": 1, + "retrieved": "2023-05-05T16:20:56.696026", + "meta": { + "show": "123abcde", + "endpoint": "playsByGender" + }, + "range": { + "start": "2023-05-01", + "end": "2023-05-04" + }, + "data": { + "stationId": 98765432, + "kind": "playsByGender", + "parameters": { + "timeRange": [] + }, + "data": { + "rows": [], + "columnHeaders": [ + { + "name": "Gender", + "type": "string" + }, + { + "name": "Percent of Plays", + "type": "number" + } + ], + "translationMapping": {}, + "colors": {} + } + } +} diff --git a/src/schema/anchor/playsByGender.json b/src/schema/anchor/playsByGender.json index b0f7fac..9f8b0ab 100644 --- a/src/schema/anchor/playsByGender.json +++ b/src/schema/anchor/playsByGender.json @@ -100,11 +100,18 @@ "type": "string" } }, - "required": [ - "Female", - "Male", - "Non-binary", - "Not specified" + "anyOf": [ + { + "maxProperties": 0 + }, + { + "required": [ + "Female", + "Male", + "Non-binary", + "Not specified" + ] + } ] }, "columnHeaders": { @@ -141,11 +148,18 @@ "type": "string" } }, - "required": [ - "Male", - "Female", - "Not specified", - "Non-binary" + "anyOf": [ + { + "maxProperties": 0 + }, + { + "required": [ + "Male", + "Female", + "Not specified", + "Non-binary" + ] + } ] } }, @@ -172,4 +186,4 @@ "meta", "data" ] -} \ No newline at end of file +} diff --git a/tests/api_e2e/anchor.test.js b/tests/api_e2e/anchor.test.js index 9125f52..618c1be 100644 --- a/tests/api_e2e/anchor.test.js +++ b/tests/api_e2e/anchor.test.js @@ -11,6 +11,7 @@ const anchorPlaysByAgeRangePayload = require('../../fixtures/anchorPlaysByAgeRan const anchorPlaysByAppPayload = require('../../fixtures/anchorPlaysByApp.json') const anchorPlaysByDevicePayload = require('../../fixtures/anchorPlaysByDevice.json') const anchorPlaysByGenderPayload = require('../../fixtures/anchorPlaysByGender.json') +const anchorPlaysByGenderEmptyPayload = require('../../fixtures/anchorPlaysByGenderEmpty.json') const anchorPlaysByGeoPayload = require('../../fixtures/anchorPlaysByGeo.json') const anchorPodcastEpisodePayload = require('../../fixtures/anchorPodcastEpisode.json') const anchorTotalPlaysPayload = require('../../fixtures/anchorTotalPlays.json') @@ -170,6 +171,16 @@ describe('check Connector API with anchorPlaysByGenderPayload', () => { }) }) +describe('check Connector API with anchorPlaysByGenderEmptyPayload', () => { + it('should return status 200 when sending Anchor playsByGender payload with empty translationMapping and colors', async () => { + const response = await request(baseURL) + .post('/connector') + .set(auth) + .send(anchorPlaysByGenderEmptyPayload) + expect(response.statusCode).toBe(200) + }) +}) + describe('check Connector API with anchorPlaysByGeoPayload', () => { it('should return status 200 when sending proper Anchor payload', async () => { const response = await request(baseURL)