UNPKG

@mapbox/mr-ui

Version:

UI components for Mapbox projects

35 lines (34 loc) 1.21 kB
"use strict"; var _styles = require("./styles"); describe('styles utils', () => { test('getStyle works with default styles', () => { expect((0, _styles.getStyle)('h1')).toBe('txt-h1-mm txt-h2 txt-fancy mb6'); expect((0, _styles.getStyle)('h1', ['txt-h1-mm', 'txt-fancy'])).toBe('txt-h2 mb6'); }); test('setStyle works', () => { (0, _styles.setStyles)({ foo: 'bar', baz: 'cat dog lion' }); expect((0, _styles.getStyle)('foo')).toBe('bar'); expect((0, _styles.getStyle)('baz', 'dog')).toBe('cat lion'); }); test('mergeStyles works', () => { // reset (0, _styles.setStyles)(); (0, _styles.mergeStyles)({ foo: 'bar', baz: 'cat dog lion', h1: 'unicorn' }); expect((0, _styles.getStyle)('foo')).toBe('bar'); expect((0, _styles.getStyle)('baz', 'dog')).toBe('cat lion'); expect((0, _styles.getStyle)('h1')).toBe('unicorn'); expect((0, _styles.getStyle)('h2')).toBe('txt-h2-mm txt-h3 txt-fancy mb6'); }); test('getStyle errors on nonexistent constant', () => { // reset (0, _styles.setStyles)(); expect(() => (0, _styles.getStyle)('foo')).toThrow(new Error('foo is not a valid constant.')); }); });