feat(xod-project): add function isPulsePin to check is Pin Type equal to Pulse

This commit is contained in:
Kirill Shumilov
2017-06-01 21:54:38 +03:00
parent 5483626133
commit ae44e47f9d
3 changed files with 23 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ export {
isTerminalPin,
normalizePinLabels,
isPinBindable,
isPulsePin,
} from './pin';
export * from './link';
export * from './constants';

View File

@@ -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

View File

@@ -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 = [