@@ -15,49 +15,83 @@ describe('Integration | Infrastructure | Utils | Pdf | Certification supervisor
15
15
} ) ;
16
16
17
17
context ( 'when lang is french' , function ( ) {
18
- it ( 'should return full french supervisor kit as a buffer' , async function ( ) {
19
- // given
20
- const lang = FRENCH_SPOKEN ;
21
- const sessionForSupervisorKit = domainBuilder . buildSessionForSupervisorKit ( {
22
- id : 12345678 ,
23
- supervisorPassword : 12344 ,
24
- accessCode : 'WB64K2' ,
25
- date : '2022-09-21' ,
26
- examiner : 'Ariete Bordeauxchesnel' ,
27
- } ) ;
28
- const expectedPdfPath = __dirname + '/kit-surveillant_expected.pdf' ;
18
+ context ( 'when session is V2' , function ( ) {
19
+ it ( 'should return full french supervisor kit as a buffer' , async function ( ) {
20
+ // given
21
+ const lang = FRENCH_SPOKEN ;
22
+ const sessionForSupervisorKit = domainBuilder . buildSessionForSupervisorKit ( {
23
+ id : 12345678 ,
24
+ supervisorPassword : 12344 ,
25
+ accessCode : 'WB64K2' ,
26
+ date : '2022-09-21' ,
27
+ examiner : 'Ariete Bordeauxchesnel' ,
28
+ } ) ;
29
+ const expectedPdfPath = __dirname + '/kit-surveillant_expected.pdf' ;
29
30
30
- // when
31
- const { buffer : actualSupervisorKitBuffer , fileName } = await getSupervisorKitPdfBuffer ( {
32
- sessionForSupervisorKit,
33
- lang,
34
- creationDate : new Date ( '2021-01-01' ) ,
31
+ // when
32
+ const { buffer : actualSupervisorKitBuffer , fileName } = await getSupervisorKitPdfBuffer ( {
33
+ sessionForSupervisorKit,
34
+ lang,
35
+ creationDate : new Date ( '2021-01-01' ) ,
36
+ } ) ;
37
+
38
+ // Note: to update the reference pdf, you can run the test with the following lines.
39
+ //
40
+ // import { writeFile } from 'fs/promises';
41
+ // await writeFile(expectedPdfPath, actualSupervisorKitBuffer);
42
+
43
+ // then
44
+ expect ( await isSameBinary ( expectedPdfPath , actualSupervisorKitBuffer ) ) . to . be . true ;
45
+ expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } .pdf` ) ;
35
46
} ) ;
36
47
37
- // Note: to update the reference pdf, you can run the test with the following lines.
38
- //
39
- // import { writeFile } from 'fs/promises';
40
- // await writeFile(expectedPdfPath, actualSupervisorKitBuffer);
48
+ context ( 'when session details contains long labels' , function ( ) {
49
+ it ( 'should return full supervisor kit as a buffer with long labels in multiple lines' , async function ( ) {
50
+ // given
51
+ const lang = FRENCH_SPOKEN ;
52
+ const sessionForSupervisorKit = domainBuilder . buildSessionForSupervisorKit ( {
53
+ id : 12345678 ,
54
+ supervisorPassword : 12344 ,
55
+ accessCode : 'WB64K2' ,
56
+ date : '2022-09-21' ,
57
+ examiner : 'Un nom très très très très très très très très très très long' ,
58
+ address : 'Une adresse qui ne tient pas sur une seule ligne' ,
59
+ room : 'Une salle particulièrement longue mais on ne sait jamais' ,
60
+ } ) ;
61
+ const expectedPdfPath = __dirname + '/kit-surveillant-with-long-labels_expected.pdf' ;
41
62
42
- // then
43
- expect ( await isSameBinary ( expectedPdfPath , actualSupervisorKitBuffer ) ) . to . be . true ;
44
- expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } .pdf` ) ;
63
+ // when
64
+ const { buffer : actualSupervisorKitBuffer , fileName } = await getSupervisorKitPdfBuffer ( {
65
+ sessionForSupervisorKit,
66
+ lang,
67
+ creationDate : new Date ( '2021-01-01' ) ,
68
+ } ) ;
69
+
70
+ // Note: to update the reference pdf, you can run the test with the following lines.
71
+ //
72
+ // import { writeFile } from 'fs/promises';
73
+ // await writeFile(expectedPdfPath, actualSupervisorKitBuffer);
74
+
75
+ // then
76
+ expect ( await isSameBinary ( expectedPdfPath , actualSupervisorKitBuffer ) ) . to . be . true ;
77
+ expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } .pdf` ) ;
78
+ } ) ;
79
+ } ) ;
45
80
} ) ;
46
81
47
- context ( 'when session details contains long labels ' , function ( ) {
48
- it ( 'should return full supervisor kit as a buffer with long labels in multiple lines ' , async function ( ) {
82
+ context ( 'when session is V3 ' , function ( ) {
83
+ it ( 'should return full french supervisor kit v3 pdf ' , async function ( ) {
49
84
// given
50
85
const lang = FRENCH_SPOKEN ;
51
86
const sessionForSupervisorKit = domainBuilder . buildSessionForSupervisorKit ( {
52
87
id : 12345678 ,
53
88
supervisorPassword : 12344 ,
54
89
accessCode : 'WB64K2' ,
55
90
date : '2022-09-21' ,
56
- examiner : 'Un nom très très très très très très très très très très long' ,
57
- address : 'Une adresse qui ne tient pas sur une seule ligne' ,
58
- room : 'Une salle particulièrement longue mais on ne sait jamais' ,
91
+ examiner : 'Ariete Bordeauxchesnel' ,
92
+ version : 3 ,
59
93
} ) ;
60
- const expectedPdfPath = __dirname + '/kit-surveillant-with-long-labels_expected .pdf' ;
94
+ const expectedPdfPath = __dirname + '/kit-surveillant_expected-v3 .pdf' ;
61
95
62
96
// when
63
97
const { buffer : actualSupervisorKitBuffer , fileName } = await getSupervisorKitPdfBuffer ( {
@@ -73,7 +107,41 @@ describe('Integration | Infrastructure | Utils | Pdf | Certification supervisor
73
107
74
108
// then
75
109
expect ( await isSameBinary ( expectedPdfPath , actualSupervisorKitBuffer ) ) . to . be . true ;
76
- expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } .pdf` ) ;
110
+ expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } -v3.pdf` ) ;
111
+ } ) ;
112
+
113
+ context ( 'when session details contains long labels' , function ( ) {
114
+ it ( 'should return full supervisor kit v3 with long labels in multiple lines' , async function ( ) {
115
+ // given
116
+ const lang = FRENCH_SPOKEN ;
117
+ const sessionForSupervisorKit = domainBuilder . buildSessionForSupervisorKit ( {
118
+ id : 12345678 ,
119
+ supervisorPassword : 12344 ,
120
+ accessCode : 'WB64K2' ,
121
+ date : '2022-09-21' ,
122
+ examiner : 'Un nom très très très très très très très très très très long' ,
123
+ address : 'Une adresse qui ne tient pas sur une seule ligne' ,
124
+ room : 'Une salle particulièrement longue mais on ne sait jamais' ,
125
+ version : 3 ,
126
+ } ) ;
127
+ const expectedPdfPath = __dirname + '/kit-surveillant-with-long-labels_expected-v3.pdf' ;
128
+
129
+ // when
130
+ const { buffer : actualSupervisorKitBuffer , fileName } = await getSupervisorKitPdfBuffer ( {
131
+ sessionForSupervisorKit,
132
+ lang,
133
+ creationDate : new Date ( '2021-01-01' ) ,
134
+ } ) ;
135
+
136
+ // Note: to update the reference pdf, you can run the test with the following lines.
137
+ //
138
+ // import { writeFile } from 'fs/promises';
139
+ // await writeFile(expectedPdfPath, actualSupervisorKitBuffer);
140
+
141
+ // then
142
+ expect ( await isSameBinary ( expectedPdfPath , actualSupervisorKitBuffer ) ) . to . be . true ;
143
+ expect ( fileName ) . to . equal ( `kit-surveillant-${ sessionForSupervisorKit . id } -v3.pdf` ) ;
144
+ } ) ;
77
145
} ) ;
78
146
} ) ;
79
147
} ) ;
0 commit comments