# All files / test-utils index.js

100% Statements 11/11
100% Branches 0/0
100% Functions 4/4
100% Lines 9/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170

    24x

    24x
    7x

    7x

    24x
    47x

    47x

    24x

    24x

     // test-utils/index.js

    import React from 'react';
    import renderer from 'react-test-renderer';
    import { shallow, mount, render } from 'enzyme';
    import { ThemeProvider } from 'styled-components';

    const defaultTheme = {
      palette: {
        common: {
          black: 'rgb(0, 0, 0)',
          white: 'rgb(255, 255, 255)',
          online: 'rgb(67, 160, 71)',
          offline: 'rgb(229, 57, 53)',
          sleeping: 'rgb(253, 216, 53)',
        },
        colors: {
          primary: {
            base: 'rgb(4, 38, 73)',
            light: 'rgb(86, 165, 246)',
            dark: 'rgb(0, 0, 0)',
          },
          accent: {
            base: 'rgb(255, 87, 50)',
            light: 'rgb(255, 171, 152)',
            dark: 'rgb(203, 37, 0)',
          },
          foreground: {
            base: 'rgb(94, 124, 139)',
            light: 'rgb(151, 173, 184)',
            dark: 'rgb(53, 70, 78)',
          },
          background: {
            base: 'rgb(255, 255, 255)',
            light: 'rgb(255, 255, 255)',
            dark: 'rgb(204, 204, 204)',
          },
        },
        contrastColors: {
          dark: {
            primary: 'rgb(255, 255, 255)',
            secondary: 'rgba(255, 255, 255, 0.7)',
            disabled: 'rgba(255, 255, 255, 0.5)',
            hint: 'rgba(255, 255, 255, 0.12)',
          },
          light: {
            primary: 'rgba(0, 0, 0, 0.87)',
            secondary: 'rgba(0, 0, 0, 0.54)',
            disabled: 'rgba(0, 0, 0, 0.38)',
            hint: 'rgba(0, 0, 0, 0.12)',
          },
        },
        error: {
          light: '#e57373',
          main: '#f44336',
          dark: '#d32f2f',
          contrastText: '#fff',
        },
        divider: 'rgba(255, 255, 255, 0.1)',
        action: {
          active: 'rgba(255, 255, 255, 0.9)',
          hover: 'rgba(255, 255, 255, 0.08)',
          selected: 'rgba(255, 255, 255, 0.14)',
          disabled: 'rgba(255, 255, 255, 0.26)',
          disabledBackground: 'rgba(255, 255, 255, 0.12)',
        },
      },
      shadows: {
        '2p': '0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12)',
        '3p': '0 3px 4px 0 rgba(0, 0, 0, 0.14), 0 3px 3px -2px rgba(0, 0, 0, 0.2), 0 1px 8px 0 rgba(0, 0, 0, 0.12)',
        '4p': '0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.2)',
        '6p': '0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.2)',
        '8p': '0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2)',
        '16p': '0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2)',
      },
      typography: {
        fontFamily: "'Nimbus sans-serif', 'Sans', 'Helvetica', 'Arial'",
        fontSize: 'calc(1 * 1px)',
        weights: {
          fontWeightUltraThin: 100,
          fontWeightThin: 300,
          fontWeightNormal: 400,
          fontWeightMedium: 500,
          fontWeightSemibold: 600,
          fontWeightBold: 700,
        },
        classes: {
          body: {
            fontSize: 'calc(16 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          caption: {
            fontSize: 'calc(12 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          footnote: {
            fontSize: 'calc(14 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          small: {
            fontSize: 'calc(10 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          headline: {
            fontSize: 'calc(24 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          subhead: {
            fontSize: 'calc(18 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          title: {
            fontSize: 'calc(20 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          jumbo: {
            fontSize: 'calc(44 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
          mega: {
            fontSize: 'calc(56 * 1px)',
            lineHeight: 'calc(16 * 1px)',
          },
        },
      },
      components: {
        conversationBox: {
          externalBackgroundColor: 'rgba(94, 124, 139, 0.1)',
          internalBackgroundColor: 'rgba(255, 213, 0, 0.2)',
          importantBackgroundColor: 'rgb(255, 246, 244)',
        },
        loader: {
          backgroundColor: 'rgb(252, 88, 48)',
        },
      },
    };

    const shallowWithTheme = (component) => {
      const context = shallow(<ThemeProvider theme={defaultTheme} />)
        .instance()
        .getChildContext();
      return shallow(component, {
        context,
        childContextTypes: ThemeProvider.childContextTypes,
      });
    };

    const mountWithTheme = (component) => {
      const context = shallow(<ThemeProvider theme={defaultTheme} />)
        .instance()
        .getChildContext();

      return mount(component, {
        context,
        childContextTypes: ThemeProvider.childContextTypes,
      });
    };

    const renderWithTheme = (component) => renderer.create(<ThemeProvider theme={defaultTheme}>{component}</ThemeProvider>);

    const staticWithTheme = (component) => render(<ThemeProvider theme={defaultTheme}>{component}</ThemeProvider>);

    export {
      defaultTheme,
      shallowWithTheme,
      mountWithTheme,
      staticWithTheme,
      renderWithTheme,
    };