mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-27 15:05:15 +02:00
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
import { expect } from 'chai';
|
|
import { describe, it } from 'mocha';
|
|
import React from 'react';
|
|
import { FormattedMessage } from 'react-intl';
|
|
import { shallowWithIntl } from './helpers/mock-intl-enzyme';
|
|
import PlatformNumber from '../../app/component/PlatformNumber';
|
|
|
|
describe('<PlatformNumber />', () => {
|
|
it('should be empty if number is undefined', () => {
|
|
const props = {
|
|
short: false,
|
|
isRailOrSubway: false,
|
|
};
|
|
const wrapper = shallowWithIntl(<PlatformNumber {...props} />);
|
|
// eslint-disable-next-line no-unused-expressions
|
|
expect(wrapper).to.be.empty;
|
|
});
|
|
|
|
it('should render message when isRailOrSubway is false', () => {
|
|
const props = {
|
|
number: '12',
|
|
short: false,
|
|
isRailOrSubway: false,
|
|
};
|
|
const wrapper = shallowWithIntl(<PlatformNumber {...props} />);
|
|
expect(wrapper.find(FormattedMessage).props().id).to.equal('platform');
|
|
});
|
|
|
|
it('should render when isRailOrSubway is true', () => {
|
|
const props = {
|
|
number: '12',
|
|
short: false,
|
|
isRailOrSubway: true,
|
|
};
|
|
const wrapper = shallowWithIntl(<PlatformNumber {...props} />);
|
|
expect(wrapper.find(FormattedMessage).props().id).to.equal('track');
|
|
});
|
|
|
|
it('should render shorter message when short is true', () => {
|
|
const props = {
|
|
number: '12',
|
|
short: true,
|
|
isRailOrSubway: false,
|
|
};
|
|
const wrapper = shallowWithIntl(<PlatformNumber {...props} />);
|
|
expect(wrapper.find('FormattedMessage').props().id).to.equal(
|
|
'platform-short-no-num',
|
|
);
|
|
});
|
|
});
|