From 4ac6259d2a82aeaf035a6e601357c536d9670070 Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Wed, 31 May 2023 15:27:30 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20isAsciicast=20check?= =?UTF-8?q?=20(#301)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: ICU-9511 --- addons/api/addon/models/channel-recording.js | 2 +- .../api/tests/unit/models/channel-recording-test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/api/addon/models/channel-recording.js b/addons/api/addon/models/channel-recording.js index c1696f9f0..eb35df41b 100644 --- a/addons/api/addon/models/channel-recording.js +++ b/addons/api/addon/models/channel-recording.js @@ -11,7 +11,7 @@ export default class ChannelRecordingModel extends GeneratedChannelRecordingMode * @type {boolean} */ get isAsciicast() { - return this.mime_types.includes(MIME_TYPE_ASCIICAST); + return this.mime_types?.includes(MIME_TYPE_ASCIICAST) ?? false; } /** diff --git a/addons/api/tests/unit/models/channel-recording-test.js b/addons/api/tests/unit/models/channel-recording-test.js index 9cf91b116..7ee3ced5b 100644 --- a/addons/api/tests/unit/models/channel-recording-test.js +++ b/addons/api/tests/unit/models/channel-recording-test.js @@ -23,4 +23,17 @@ module('Unit | Model | channel-recording', function (hooks) { assert.true(modelA.isAsciicast); assert.false(modelB.isAsciicast); }); + + test('it has isAsciicast property and returns the expected values when mime_types are not present', async function (assert) { + assert.expect(2); + const store = this.owner.lookup('service:store'); + const modelA = store.createRecord('channel-recording', { + mime_types: undefined, + }); + const modelB = store.createRecord('channel-recording', { + mime_types: [], + }); + assert.false(modelA.isAsciicast); + assert.false(modelB.isAsciicast); + }); });