mirror of
https://github.com/xodio/xod.git
synced 2026-03-25 01:56:54 +01:00
feat(xod-project): add function isPulsePin to check is Pin Type equal to Pulse
This commit is contained in:
@@ -45,6 +45,7 @@ export {
|
||||
isTerminalPin,
|
||||
normalizePinLabels,
|
||||
isPinBindable,
|
||||
isPulsePin,
|
||||
} from './pin';
|
||||
export * from './link';
|
||||
export * from './constants';
|
||||
|
||||
@@ -156,6 +156,18 @@ export const isTerminalPin = def(
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks pin type to be Pulse
|
||||
* TODO: Add functions for other types when needed.
|
||||
*/
|
||||
export const isPulsePin = def(
|
||||
'isPulsePin :: Pin -> Boolean',
|
||||
R.compose(
|
||||
R.equals(CONST.PIN_TYPE.PULSE),
|
||||
getPinType
|
||||
)
|
||||
);
|
||||
|
||||
// =============================================================================
|
||||
//
|
||||
// Setters
|
||||
|
||||
@@ -79,6 +79,16 @@ describe('Pin', () => {
|
||||
expect(Pin.isTerminalPin(pin)).to.be.true();
|
||||
});
|
||||
});
|
||||
describe('isPulsePin', () => {
|
||||
it('should return false for non-pulse pin', () => {
|
||||
const pin = Helper.defaultizePin({ type: CONST.PIN_TYPE.STRING });
|
||||
expect(Pin.isPulsePin(pin)).to.be.false();
|
||||
});
|
||||
it('should return true for pulse pin', () => {
|
||||
const pin = Helper.defaultizePin({ type: CONST.PIN_TYPE.PULSE });
|
||||
expect(Pin.isPulsePin(pin)).to.be.true();
|
||||
});
|
||||
});
|
||||
describe('normalizePinLabels', () => {
|
||||
it('should return list of pins with unique labels', () => {
|
||||
const pins = [
|
||||
|
||||
Reference in New Issue
Block a user