@@ -151,6 +151,7 @@ describe("Update confirmation statement POST", () => {
151151 const updatedConfirmationStatement = data . resource ;
152152 const mockSubmission = mockValues . mockConfirmationStatementSubmissionResource ;
153153 expect ( updatedConfirmationStatement . id ) . to . equal ( mockSubmission . id ) ;
154+ expect ( updatedConfirmationStatement . data . confirmationStatementMadeUpToDate ) . to . equal ( mockSubmission . data . confirmation_statement_made_up_to_date ) ;
154155 expect ( updatedConfirmationStatement . data . statementOfCapitalData . sectionStatus ) . to . equal ( mockSubmission . data . statement_of_capital_data . section_status ) ;
155156 expect ( updatedConfirmationStatement . data . statementOfCapitalData . statementOfCapital . classOfShares ) . to . equal ( mockSubmission . data . statement_of_capital_data . statement_of_capital . class_of_shares ) ;
156157 expect ( updatedConfirmationStatement . data . sicCodeData . sectionStatus ) . to . equal ( mockSubmission . data . sic_code_data . section_status ) ;
@@ -342,12 +343,14 @@ describe("confirmation statement submission GET", () => {
342343 const data : Resource < ConfirmationStatementSubmission > =
343344 await csService . getConfirmationStatementSubmission ( TRANSACTION_ID , CONFIRMATION_STATEMENT_ID ) as Resource < ConfirmationStatementSubmission > ;
344345
346+ const mockResource = mockValues . mockConfirmationStatementSubmissionResource ;
345347 expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
346- expect ( data . resource . id ) . to . equal ( mockValues . mockConfirmationStatementSubmissionResource . id ) ;
347- expect ( data . resource . links ) . to . equal ( mockValues . mockConfirmationStatementSubmissionResource . links )
348- expect ( data . resource . data . statementOfCapitalData . sectionStatus ) . to . equal ( mockValues . mockConfirmationStatementSubmissionResource . data . statement_of_capital_data . section_status ) ;
348+ expect ( data . resource . id ) . to . equal ( mockResource . id ) ;
349+ expect ( data . resource . links ) . to . equal ( mockResource . links ) ;
350+ expect ( data . resource . data . confirmationStatementMadeUpToDate ) . to . equal ( mockResource . data . confirmation_statement_made_up_to_date ) ;
351+ expect ( data . resource . data . statementOfCapitalData . sectionStatus ) . to . equal ( mockResource . data . statement_of_capital_data . section_status ) ;
349352 const statementOfCapital : StatementOfCapital = data . resource . data . statementOfCapitalData . statementOfCapital ;
350- const mockStatementOfCapital : StatementOfCapitalResource = mockValues . mockConfirmationStatementSubmissionResource . data . statement_of_capital_data . statement_of_capital
353+ const mockStatementOfCapital : StatementOfCapitalResource = mockResource . data . statement_of_capital_data . statement_of_capital
351354 expect ( statementOfCapital . aggregateNominalValue ) . to . equal ( mockStatementOfCapital . aggregate_nominal_value ) ;
352355 expect ( statementOfCapital . classOfShares ) . to . equal ( mockStatementOfCapital . class_of_shares ) ;
353356 expect ( statementOfCapital . currency ) . to . equal ( mockStatementOfCapital . currency ) ;
@@ -370,18 +373,6 @@ describe("confirmation statement submission GET", () => {
370373 expect ( data . resource . data ) . to . equal ( undefined ) ;
371374 } ) ;
372375
373- it ( "should return confirmation statement submission object with empty data" , async ( ) => {
374- sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockConfirmationStatementSubmissionResourceEmptyData } ) ;
375- const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
376- const data : Resource < ConfirmationStatementSubmission > =
377- await csService . getConfirmationStatementSubmission ( TRANSACTION_ID , CONFIRMATION_STATEMENT_ID ) as Resource < ConfirmationStatementSubmission > ;
378-
379- expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
380- expect ( data . resource . id ) . to . equal ( mockValues . mockConfirmationStatementSubmissionResourceEmptyData . id ) ;
381- expect ( data . resource . links ) . to . equal ( mockValues . mockConfirmationStatementSubmissionResourceEmptyData . links )
382- expect ( data . resource . data ) . to . deep . equal ( mockValues . mockConfirmationStatementSubmissionResourceEmptyData . data ) ;
383- } ) ;
384-
385376 it ( "should return confirmation statement submission object with no statement of capital" , async ( ) => {
386377 sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockConfirmationStatementSubmissionResourceNoSOC } ) ;
387378 const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
@@ -404,52 +395,52 @@ describe("confirmation statement submission GET", () => {
404395 expect ( data . httpStatusCode ) . to . equal ( 404 ) ;
405396 expect ( data . errors [ 0 ] ) . to . equal ( "No confirmation statement submission found" ) ;
406397 } ) ;
398+ } ) ;
399+
400+ describe ( "getNextMadeUpToDate tests" , ( ) => {
401+ it ( "Should not map optional fields when filing is due" , async ( ) => {
402+ sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceIsDue } ) ;
403+ const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
404+ const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
405+ const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
406+
407+ expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
408+ expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsDue . current_next_made_up_to_date ) ;
409+ expect ( nextMadeUpToDate . isDue ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsDue . is_due ) ;
410+ expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . be . undefined ;
411+ } )
412+
413+ it ( "Should map optional fields when filing is not due" , async ( ) => {
414+ sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceIsNotDue } ) ;
415+ const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
416+ const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
417+ const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
418+
419+ expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
420+ expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . current_next_made_up_to_date ) ;
421+ expect ( nextMadeUpToDate . isDue ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . is_due ) ;
422+ expect ( nextMadeUpToDate . newNextMadeUpToDate ) . not . to . be . undefined ;
423+ expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . new_next_made_up_to_date ) ;
424+ } )
425+
426+ it ( "Should not map optional fields when no cs found in company profile" , async ( ) => {
427+ sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceNoCs } ) ;
428+ const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
429+ const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
430+ const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
431+
432+ expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
433+ expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . be . null ;
434+ expect ( nextMadeUpToDate . isDue ) . to . be . undefined
435+ expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . be . undefined ;
436+ } )
437+
438+ it ( "Should return an error when api response status >= 400" , async ( ) => {
439+ sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 404 , error : "Not Found" } ) ;
440+ const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
441+ const response : ApiErrorResponse = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as ApiErrorResponse ;
407442
408- describe ( "getNextMadeUpToDate tests" , ( ) => {
409- it ( "Should not map optional fields when filing is due" , async ( ) => {
410- sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceIsDue } ) ;
411- const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
412- const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
413- const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
414-
415- expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
416- expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsDue . current_next_made_up_to_date ) ;
417- expect ( nextMadeUpToDate . isDue ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsDue . is_due ) ;
418- expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . be . undefined ;
419- } )
420-
421- it ( "Should map optional fields when filing is not due" , async ( ) => {
422- sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceIsNotDue } ) ;
423- const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
424- const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
425- const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
426-
427- expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
428- expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . current_next_made_up_to_date ) ;
429- expect ( nextMadeUpToDate . isDue ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . is_due ) ;
430- expect ( nextMadeUpToDate . newNextMadeUpToDate ) . not . to . be . undefined ;
431- expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . equal ( mockValues . mockNextMadeUpToDateResourceIsNotDue . new_next_made_up_to_date ) ;
432- } )
433-
434- it ( "Should not map optional fields when no cs found in company profile" , async ( ) => {
435- sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 200 , body : mockValues . mockNextMadeUpToDateResourceNoCs } ) ;
436- const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
437- const response : Resource < NextMadeUpToDate > = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as Resource < NextMadeUpToDate > ;
438- const nextMadeUpToDate : NextMadeUpToDate = response . resource ;
439-
440- expect ( response . httpStatusCode ) . to . equal ( 200 ) ;
441- expect ( nextMadeUpToDate . currentNextMadeUpToDate ) . to . be . null ;
442- expect ( nextMadeUpToDate . isDue ) . to . be . undefined
443- expect ( nextMadeUpToDate . newNextMadeUpToDate ) . to . be . undefined ;
444- } )
445-
446- it ( "Should return an error when api response status >= 400" , async ( ) => {
447- sinon . stub ( mockValues . requestClient , "httpGet" ) . resolves ( { status : 404 , error : "Not Found" } ) ;
448- const csService : ConfirmationStatementService = new ConfirmationStatementService ( mockValues . requestClient ) ;
449- const response : ApiErrorResponse = await csService . getNextMadeUpToDate ( COMPANY_NUMBER ) as ApiErrorResponse ;
450-
451- expect ( response . httpStatusCode ) . to . equal ( 404 ) ;
452- expect ( response . errors [ 0 ] ) . to . equal ( "Not Found" ) ;
453- } )
443+ expect ( response . httpStatusCode ) . to . equal ( 404 ) ;
444+ expect ( response . errors [ 0 ] ) . to . equal ( "Not Found" ) ;
454445 } )
455446} ) ;
0 commit comments