34 | {{ message_content }}
35 |
36 |
37 | Abraaaaço!
38 | Diego Fernandes
39 | CTO | Rocketseat
40 |
41 |
42 | `,
43 | };
44 |
45 | await createTemplate.execute({ data: templateData });
46 |
47 | const template = await Template.findOne(templateData);
48 |
49 | expect(template).toBeTruthy();
50 | });
51 |
52 | it('should not be able to create template without {{message_content}}', async () => {
53 | expect.assertions(1);
54 |
55 | try {
56 | const createTemplate = new CreateTemplateService();
57 |
58 | const templateData = {
59 | title: 'Rocketseat',
60 | content: `Template without content`,
61 | };
62 |
63 | await createTemplate.execute({ data: templateData });
64 | } catch (err) {
65 | expect(err).toBeInstanceOf(Error);
66 | }
67 | });
68 | });
69 |
--------------------------------------------------------------------------------
/packages/web/src/components/Button/index.tsx:
--------------------------------------------------------------------------------
1 | import styled, { css } from 'styled-components';
2 | import { shade, tint } from 'polished';
3 |
4 | interface Props {
5 | size?: 'small' | 'default' | 'big';
6 | color?: 'primary' | 'secundary' | 'cancel' | 'danger';
7 | loading?: boolean;
8 | inline?: boolean;
9 | }
10 |
11 | const sizes = {
12 | small: css`
13 | padding: 4px 8px;
14 | font-size: 12px;
15 | `,
16 | default: css`
17 | padding: 6px 12px;
18 | font-size: 14px;
19 | `,
20 | big: css`
21 | padding: 14px 20px;
22 | font-size: 15px;
23 | `,
24 | };
25 |
26 | const colors = {
27 | primary: css`
28 | background: #7159c1;
29 | color: #fff;
30 |
31 | &:hover {
32 | background: ${shade(0.1, '#7159c1')};
33 | }
34 | `,
35 | secundary: css`
36 | background: #ff79c6;
37 | color: #fff;
38 |
39 | &:hover {
40 | background: ${shade(0.1, '#FF79C6')};
41 | }
42 | `,
43 | danger: css`
44 | background: #e96379;
45 | color: #fff;
46 |
47 | &:hover {
48 | background: ${shade(0.1, '#E96379')};
49 | }
50 | `,
51 | cancel: css`
52 | background: transparent;
53 | border: 2px solid ${props => tint(0.3, '#7159c1')};
54 | color: ${props => tint(0.3, '#7159c1')};
55 |
56 | &:hover {
57 | background: transparent;
58 | color: #7159c1;
59 | border-color: #7159c1;
60 | }
61 | `,
62 | };
63 |
64 | const ButtonStyled = styled.button.attrs