Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugFix resolving type mismatch w.r.t DescriptorType #4463

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dash/vo/DescriptorType.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DescriptorType {
init(data) {
if (data) {
this.schemeIdUri = data.schemeIdUri ? data.schemeIdUri : null;
this.value = data.value ? data.value : null;
this.value = data.value ? data.value.toString() : null;
this.id = data.id ? data.id : null;
// Only add the DVB extensions if they exist
if (data[DashConstants.DVB_URL]) {
Expand All @@ -65,7 +65,7 @@ class DescriptorType {
return (
this.schemeIdUri === entry.schemeIdUri && (
this.value ?
(this.value.match(entry.value)) : // check if provided value matches RegExp
(this.value.toString().match(entry.value)) : // check if provided value matches RegExp
(''.match(entry.value)) // check if RegExp allows absent value
)
);
Expand Down
149 changes: 120 additions & 29 deletions test/unit/test/dash/dash.vo.DescriptorType.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,135 @@
import DescriptorType from '../../../../src/dash/vo/DescriptorType.js';

import {expect} from 'chai';
import { expect } from 'chai';

describe('DescriptorType', () => {

it('should be constructed with null values', () => {
const dt = new DescriptorType();
expect(dt).to.deep.equal({
schemeIdUri: null,
value: null,
id: null
describe('Initialization', () => {
it('should be constructed with null values', () => {
const dt = new DescriptorType();
expect(dt).to.deep.equal({
schemeIdUri: null,
value: null,
id: null
});
});
});

it('should initialise with correct base values', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: '1',
it('should initialise with correct base values', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: '1',
});
expect(dt).to.deep.equal({
schemeIdUri: 'testScheme',
value: '1',
id: null
});
});
expect(dt).to.deep.equal({
schemeIdUri: 'testScheme',
value: '1',
id: null

it('should initialise with correct base values and type conversion', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 1,
});
expect(dt).to.deep.equal({
schemeIdUri: 'testScheme',
value: '1',
id: null
});
});

it('should initialise with known dvb extensions if present', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: '1',
'dvb:url': 'testUrl'
});
expect(dt).to.deep.equal({
schemeIdUri: 'testScheme',
value: '1',
id: null,
dvbUrl: 'testUrl'
});
});
});

it('should initialise with known dvb extensions if present', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: '1',
'dvb:url': 'testUrl'
describe('inArray', () => {
it('should return false array is empty', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 10
});
const testArray = [];

let ret = dt.inArray(testArray);
expect(ret).to.be.false;
});
expect(dt).to.deep.equal({
schemeIdUri: 'testScheme',
value: '1',
id: null,
dvbUrl: 'testUrl'

it('should find a descriptor if only the schemeIdUri is provided', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 10
});
const testArray = [
{ schemeIdUri: 'notSupportedTestScheme' },
{ schemeIdUri: 'testScheme' },
{ schemeIdUri: 'notSupported' }
];

let ret = dt.inArray(testArray);
expect(ret).to.be.true;
});
});

it('should not erroneously match a descriptor if different schemeIdUri are provided', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 10
});
const testArray = [
{ schemeIdUri: 'notSupportedTestScheme' },
{ schemeIdUri: 'notSupported' }
];

let ret = dt.inArray(testArray);
expect(ret).to.be.false;
});

it('should find a descriptor if schemeIdUri and value is provided', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 2
});
const testArray = [
{ schemeIdUri: 'notSupportedTestScheme', value: '1' },
{ schemeIdUri: 'testScheme', value: '2' },
{ schemeIdUri: 'notSupported', value: '3' }
];

let ret = dt.inArray(testArray);
expect(ret).to.be.true;
});

it('should not find a descriptor if schemeIdUri is provided and value not matches', () => {
const dt = new DescriptorType();
dt.init({
schemeIdUri: 'testScheme',
value: 3
});
const testArray = [
{ schemeIdUri: 'notSupportedTestScheme', value: '1' },
{ schemeIdUri: 'testScheme', value: '1' },
{ schemeIdUri: 'notSupported', value: '1' }
];

let ret = dt.inArray(testArray);
expect(ret).to.be.false;
});
});
});