FIX tests

This commit is contained in:
Norbert de Langen 2019-04-27 17:17:57 +02:00
parent fbcfdb9df1
commit f09fa53cf9
2 changed files with 59 additions and 55 deletions

View File

@ -0,0 +1,58 @@
import { convert } from '../convert';
import { create } from '../create';
import darkThemeVars from '../themes/dark';
import lightThemeVars from '../themes/light';
describe('convert', () => {
it('should return the default theme when no params', () => {
const result = convert();
expect(result.base).toEqual('light');
});
it('should return a valid dark theme', () => {
const result = convert(darkThemeVars);
expect(result.base).toEqual('dark');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#2f2f2f',
}),
});
});
it('should return a valid light theme', () => {
const result = convert(lightThemeVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#F6F9FC',
}),
});
});
it('should map optional vars', () => {
const customVars = create({
base: 'light',
brandTitle: 'my custom storybook',
gridCellSize: 12,
});
const result = convert(customVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
background: expect.objectContaining({
gridCellSize: 12,
}),
brand: expect.objectContaining({
title: 'my custom storybook',
}),
});
});
});

View File

@ -1,4 +1,4 @@
import { create, convert } from '../create';
import { create } from '../create';
import darkThemeVars from '../themes/dark';
import lightThemeVars from '../themes/light';
@ -132,57 +132,3 @@ describe('create extend', () => {
expect(result.base).toEqual('light');
});
});
describe('convert', () => {
it('should return the default theme when no params', () => {
const result = convert();
expect(result.base).toEqual('light');
});
it('should return a valid dark theme', () => {
const result = convert(darkThemeVars);
expect(result.base).toEqual('dark');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#2f2f2f',
}),
});
});
it('should return a valid light theme', () => {
const result = convert(lightThemeVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
color: expect.objectContaining({
primary: '#FF4785',
secondary: '#1EA7FD',
}),
background: expect.objectContaining({
app: '#F6F9FC',
}),
});
});
it('should map optional vars', () => {
const customVars = create({
base: 'light',
brandTitle: 'my custom storybook',
gridCellSize: 12,
});
const result = convert(customVars);
expect(result.base).toEqual('light');
expect(result).toMatchObject({
background: expect.objectContaining({
gridCellSize: 12,
}),
brand: expect.objectContaining({
title: 'my custom storybook',
}),
});
});
});