diff options
author | Mike Gerwitz <mike.gerwitz@rtspecialty.com> | 2019-10-23 12:09:27 -0400 |
---|---|---|
committer | Mike Gerwitz <mike.gerwitz@rtspecialty.com> | 2019-10-29 13:36:41 -0400 |
commit | 767a248e44db49ee3dee0b5131c2af00d264a93b (patch) | |
tree | 60fc4a319a9c569fb51035a5ebb48f53fb56d78c /test | |
parent | 8f7afd22e50b1718e062c54701e258e5ca2ad715 (diff) | |
download | liza-767a248e44db49ee3dee0b5131c2af00d264a93b.tar.gz liza-767a248e44db49ee3dee0b5131c2af00d264a93b.tar.bz2 liza-767a248e44db49ee3dee0b5131c2af00d264a93b.zip |
RatingService: Convert to TypeScript
This was an adventure, and was also used as a peer programming exercise to
introduce TypeScript to other programmers in the office.
This class has far too many dependencies, which made this difficult. The
approach was to create .d.ts files for dependencies and wait on moving those
over for now, otherwise the task will never get done.
The RatingServicePublic trait was left as such for the time being; I was
able to work around a bug that was making it difficult to mix it into a
prototype.
There were no logic changes; this was just type refactoring.
Diffstat (limited to 'test')
-rw-r--r-- | test/server/service/RatingServiceTest.ts (renamed from test/server/service/RatingServiceTest.js) | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/test/server/service/RatingServiceTest.js b/test/server/service/RatingServiceTest.ts index b04c354..8330bea 100644 --- a/test/server/service/RatingServiceTest.js +++ b/test/server/service/RatingServiceTest.ts @@ -19,10 +19,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -'use strict' +import { expect } from 'chai'; +import { RatingService as Sut } from "../../../src/server/service/RatingService"; -const { expect } = require( 'chai' ); -const Sut = require( '../../../' ).server.service.RatingService; const RatingServiceStub = require( '../../../' ).test.server.service.RatingServiceStub; describe( 'RatingService', () => @@ -49,15 +48,13 @@ describe( 'RatingService', () => done(); }; - const sut = Sut.extend( + const sut = new class extends Sut { - 'override postProcessRaterData'( - request, data, actions, program, quote - ) + postProcessRaterData() { processed = true; } - } )( logger, dao, server, raters ); + }( logger, dao, server, raters ); sut.request( request, response, quote, 'something', () => {} ); } ); @@ -87,9 +84,9 @@ describe( 'RatingService', () => quote.getRatedDate = () => initial_date; - const sut = Sut( logger, dao, server, raters ); + const sut = new Sut( logger, dao, server, raters ); - server.sendResponse = ( request, quote, resp, actions ) => + server.sendResponse = ( _request: any, _quote: any, resp: any, _actions: any ) => { expect( getLastPremiumDateCallCount ).to.equal( 2 ); expect( resp.initialRatedDate ).to.equal( initial_date ); @@ -98,7 +95,7 @@ describe( 'RatingService', () => done(); }; - sut.request( request, response, quote, null, () => {} ); + sut.request( request, response, quote, "", () => {} ); } ); } ); |