|
1 |
| -import { EventSection } from '../event-section'; |
2 |
| -import { EventSpot } from '../event-spot'; |
3 | 1 | import { Event } from '../event.entity';
|
4 | 2 | import { PartnerId } from '../partner.entity';
|
| 3 | +import { initOrm } from './helpers'; |
5 | 4 |
|
6 |
| -test('deve criar um evento', () => { |
7 |
| - const event = Event.create({ |
8 |
| - name: 'Evento 1', |
9 |
| - description: 'Descrição do evento 1', |
10 |
| - date: new Date(), |
11 |
| - partner_id: new PartnerId(), |
12 |
| - }); |
13 |
| - |
14 |
| - event.addSection({ |
15 |
| - name: 'Sessão 1', |
16 |
| - description: 'Descrição da sessão 1', |
17 |
| - total_spots: 100, |
18 |
| - price: 1000, |
19 |
| - }); |
| 5 | +describe('Event Entity Unit Tests', () => { |
| 6 | + initOrm(); |
| 7 | + it('deve criar um evento', () => { |
| 8 | + const event = Event.create({ |
| 9 | + name: 'Evento 1', |
| 10 | + description: 'Descrição do evento 1', |
| 11 | + date: new Date(), |
| 12 | + partner_id: new PartnerId(), |
| 13 | + }); |
20 | 14 |
|
21 |
| - expect(event._sections.size).toBe(1); |
22 |
| - expect(event.total_spots).toBe(100); |
| 15 | + event.addSection({ |
| 16 | + name: 'Sessão 1', |
| 17 | + description: 'Descrição da sessão 1', |
| 18 | + total_spots: 100, |
| 19 | + price: 1000, |
| 20 | + }); |
23 | 21 |
|
24 |
| - const [section] = event._sections; |
| 22 | + expect(event.sections.size).toBe(1); |
| 23 | + expect(event.total_spots).toBe(100); |
25 | 24 |
|
26 |
| - expect(section.spots.size).toBe(100); |
| 25 | + const [section] = event.sections; |
27 | 26 |
|
28 |
| - // const spot = EventSpot.create(); |
| 27 | + expect(section.spots.size).toBe(100); |
29 | 28 |
|
30 |
| - // section.spots.add(spot); |
| 29 | + // const spot = EventSpot.create(); |
31 | 30 |
|
32 |
| - // console.dir(event.toJSON(), { depth: 10 }); |
| 31 | + // section.spots.add(spot); |
33 | 32 |
|
34 |
| - // não é valido |
35 |
| - // customer = new Customer({ |
36 |
| - // id: '123', new CustomerId() || new CustomerId('') |
37 |
| - // name: 'João', |
38 |
| - // cpf: '99346413050', |
39 |
| - // }); |
40 |
| -}); |
41 |
| - |
42 |
| -test('deve publicar todos os itens do evento', () => { |
43 |
| - const event = Event.create({ |
44 |
| - name: 'Evento 1', |
45 |
| - description: 'Descrição do evento 1', |
46 |
| - date: new Date(), |
47 |
| - partner_id: new PartnerId(), |
48 |
| - }); |
| 33 | + // console.dir(event.toJSON(), { depth: 10 }); |
49 | 34 |
|
50 |
| - event.addSection({ |
51 |
| - name: 'Sessão 1', |
52 |
| - description: 'Descrição da sessão 1', |
53 |
| - total_spots: 100, |
54 |
| - price: 1000, |
| 35 | + // não é valido |
| 36 | + // customer = new Customer({ |
| 37 | + // id: '123', new CustomerId() || new CustomerId('') |
| 38 | + // name: 'João', |
| 39 | + // cpf: '99346413050', |
| 40 | + // }); |
55 | 41 | });
|
56 | 42 |
|
57 |
| - event.addSection({ |
58 |
| - name: 'Sessão 2', |
59 |
| - description: 'Descrição da sessão 2', |
60 |
| - total_spots: 1000, |
61 |
| - price: 50, |
62 |
| - }); |
63 |
| - |
64 |
| - event.publishAll(); |
65 |
| - |
66 |
| - expect(event.is_published).toBe(true); |
67 |
| - |
68 |
| - const [section1, section2] = event._sections.values(); |
69 |
| - expect(section1.is_published).toBe(true); |
70 |
| - expect(section2.is_published).toBe(true); |
71 |
| - |
72 |
| - [...section1.spots, ...section2.spots].forEach((spot) => { |
73 |
| - expect(spot.is_published).toBe(true); |
| 43 | + test('deve publicar todos os itens do evento', () => { |
| 44 | + const event = Event.create({ |
| 45 | + name: 'Evento 1', |
| 46 | + description: 'Descrição do evento 1', |
| 47 | + date: new Date(), |
| 48 | + partner_id: new PartnerId(), |
| 49 | + }); |
| 50 | + |
| 51 | + event.addSection({ |
| 52 | + name: 'Sessão 1', |
| 53 | + description: 'Descrição da sessão 1', |
| 54 | + total_spots: 100, |
| 55 | + price: 1000, |
| 56 | + }); |
| 57 | + |
| 58 | + event.addSection({ |
| 59 | + name: 'Sessão 2', |
| 60 | + description: 'Descrição da sessão 2', |
| 61 | + total_spots: 1000, |
| 62 | + price: 50, |
| 63 | + }); |
| 64 | + |
| 65 | + event.publishAll(); |
| 66 | + |
| 67 | + expect(event.is_published).toBe(true); |
| 68 | + |
| 69 | + const [section1, section2] = event._sections.values(); |
| 70 | + expect(section1.is_published).toBe(true); |
| 71 | + expect(section2.is_published).toBe(true); |
| 72 | + |
| 73 | + [...section1.spots, ...section2.spots].forEach((spot) => { |
| 74 | + expect(spot.is_published).toBe(true); |
| 75 | + }); |
74 | 76 | });
|
75 | 77 | });
|
0 commit comments