-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(temporal-set): Code did not match spec
Merge pull request #89 from rdkcentral/fix/temporal-set
- Loading branch information
Showing
6 changed files
with
160 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 20 additions & 8 deletions
28
languages/javascript/templates/declarations/temporal-set.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
interface ${method.item.type}Process { | ||
stop(): void | ||
} | ||
|
||
/** | ||
* ${method.summary} | ||
* Live list: ${method.summary} | ||
* | ||
${method.params.annotations} * @param {Function} add A method for receiving ${method.item.type} objects as they become available${if.deprecated} | ||
* @deprecated ${method.deprecation} | ||
${method.params.annotations} * @param {Function} add A method for receiving ${method.item.type} objects as they become available | ||
* @param {Function} remove A method for receiving ${method.item.type} objects as they become unavailable | ||
${if.deprecated} * @deprecated ${method.deprecation} | ||
${end.if.deprecated} */ | ||
function ${method.name}(${method.signature.params}${if.context}, ${end.if.context} add: (${method.item}: ${method.item.type}) => void): { stop: () => void } | ||
function ${method.name}(${method.signature.params}${if.context}, ${end.if.context} add: (${method.item}: ${method.item.type}) => void, remove: (${method.item}: ${method.item.type}) => void): ${method.item.type}Process | ||
|
||
/** | ||
* ${method.summary} | ||
* First match: ${method.summary} | ||
* | ||
${method.params.annotations} * @param {Function} add A method for receiving ${method.item.type} objects as they become available | ||
* @param {Function} remove A method for receiving ${method.item.type} objects as they become unavailable | ||
${method.params.annotations} * @param {Function} timeout How long, in ms, to wait for a match | ||
${if.deprecated} * @deprecated ${method.deprecation} | ||
${end.if.deprecated} */ | ||
function ${method.name}(${method.signature.params}${if.context}, ${end.if.context} timeout: number): Promise<${method.item.type}> | ||
|
||
/** | ||
* Known values w/out updates: ${method.summary} | ||
* | ||
${method.params.annotations} | ||
${if.deprecated} * @deprecated ${method.deprecation} | ||
${end.if.deprecated} */ | ||
function ${method.name}(${method.signature.params}${if.context}, ${end.if.context} add: (${method.item}: ${method.item.type}) => void, remove: (${method.item}: ${method.item.type}) => void): { stop: () => void } | ||
function ${method.name}(${method.signature.params}): Promise<${method.item.type}[]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
function ${method.name}(...args) { | ||
let add, remove | ||
let add, remove, timeout | ||
if (typeof args[args.length-1] === 'function' && typeof args[args.length-2] === 'function') { | ||
remove = args.pop() | ||
add = args.pop() | ||
} | ||
else if (typeof args[args.length-1] === 'function') { | ||
add = args.pop() | ||
} | ||
else if (typeof args[args.length-1] === 'number') { | ||
timeout = args.pop() | ||
} | ||
|
||
const transforms = ${method.transforms} | ||
|
||
return TemporalSet.start('${info.title}', '${method.name}', '${method.temporalset.add}', '${method.temporalset.remove}', arguments, add, remove, transforms) | ||
return TemporalSet.start('${info.title}', '${method.name}', '${method.temporalset.add}', '${method.temporalset.remove}', args, add, remove, timeout, transforms) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2021 Comcast Cable Communications Management, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Advanced } from '../../build/sdk/javascript/src/sdk.mjs' | ||
import Setup from '../Setup' | ||
import { expect } from '@jest/globals'; | ||
|
||
test('Temporal Set - all known values', () => { | ||
return Advanced.list().then(items => { | ||
console.dir(items) | ||
expect(Array.isArray(items)).toBe(true) | ||
}) | ||
}) | ||
|
||
test('Temporal Set - first match', () => { | ||
return Advanced.list(10000).then(item => { | ||
console.dir(item) | ||
expect(Array.isArray(item)).toBe(false) | ||
}) | ||
}) | ||
|
||
|
||
test('Temporal Set - live list', () => { | ||
|
||
return new Promise( (resolve, reject) => { | ||
const process = Advanced.list((item) => { | ||
// add | ||
console.dir(item) | ||
expect(item.aString).toBe("Here's a string") | ||
expect(item.aNumber).toBe(123) | ||
expect(typeof item.aMethod).toBe('function') | ||
item.aMethod().then(result => { | ||
expect(result.foo).toBe("here's foo") | ||
expect(result.bar).toBe(1) | ||
resolve() | ||
}) | ||
}, | ||
(item) => { | ||
// remove | ||
}) | ||
|
||
expect(typeof process.stop).toBe('function') | ||
}) | ||
}) |