vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
72 lines (70 loc) • 2.18 kB
JavaScript
import React from 'react';
import { Logo } from '.';
import { getImagesSrc } from './helpers';
import createSnapshot from '../../test/create-snapshot';
import render from '../../test/render';
describe('<Logo />', function () {
it('correctly implements ref prop', function () {
var mockRef = React.createRef();
render(React.createElement(Logo, {
ref: mockRef
}));
expect(mockRef.current).not.toBe(null);
});
it('renders correctly with type=LOGO_TYPES.WORDMARK ', function () {
var snapshot = createSnapshot(React.createElement(Logo, {
type: "wordmark"
}));
expect(snapshot).toMatchSnapshot();
});
it('renders <Logo /> correctly with theme', function () {
var theme = {
logoImages: {
square: 'polestar-logo.png',
square2x: 'polestar-logo-2x.png',
wordmark: 'polestar-wordmark-white.png',
wordmark2x: 'polestar-wordmark-white-2x.png'
},
logoImagesPath: '/logo/testpath/',
logoTypes: {
SQUARE: 'square',
WORDMARK: 'wordmark'
},
styles: {
logo: {
color: '#ffffff'
}
}
};
var snapshot = createSnapshot(React.createElement(Logo, {
type: theme.logoTypes.WORDMARK,
alt: "Polestar"
}), theme);
expect(snapshot).toMatchSnapshot();
});
});
describe('<Logo /> helper tests', function () {
it('returns theme images srcSet', function () {
var theme = {
logoImages: {
square: 'polestar-logo.png',
square2x: 'polestar-logo-2x.png',
wordmark: 'polestar-wordmark-white.png',
wordmark2x: 'polestar-wordmark-white-2x.png'
},
logoImagesPath: '/logo/testpath/',
logoTypes: {
SQUARE: 'square',
wordmark: 'wordmark'
}
};
var _getImagesSrc = getImagesSrc({
type: theme.logoTypes.SQUARE,
theme: theme
}),
src = _getImagesSrc.src,
srcSet = _getImagesSrc.srcSet;
expect(src).toEqual("".concat(theme.logoImagesPath).concat(theme.logoImages.square));
expect(srcSet).toEqual("".concat(src, ", ").concat(theme.logoImagesPath).concat(theme.logoImages.square2x, " 2x"));
});
});