Commit Graph

54 Commits

Author SHA1 Message Date
Dev
60ead44b30 Add HealthController.healthTreatment() tests 2023-11-18 15:01:51 +00:00
Refringe
5d2af422cb
Fixes InsuranceController Tests 2023-11-16 23:55:32 -05:00
Refringe
0793df60c2
Formatting Change - Space is now given around object properties. 2023-11-13 12:38:16 -05:00
Refringe
32b47bdc18
Formatting Change - When a statement can be moved into a single line and still be under the maximum line length, it is. 2023-11-13 12:31:52 -05:00
Refringe
11b5c76512
Favours single line variable declarations. 2023-11-13 11:51:52 -05:00
Refringe
ce45862e75
Favours dot object notation whenever possible. 2023-11-13 11:51:02 -05:00
Refringe
e709b6c111
Reformatted imports with (only) Biome. 2023-11-13 11:43:37 -05:00
Refringe
320c8b7d48
Formatting for test classes. 2023-11-10 17:21:20 -05:00
Dev
43eadcbfa9 Update test to make use of string literals 2023-11-08 08:59:28 +00:00
Refringe
0ad85b45e1
Small ItemHelper.getRandomCompatibleCaliberTemplateId() Improvements
- Updated to safely access a deeply nested property.
- Updated to safely access the item `_id` and `_name` properties in the warning log.
- Updated to use the `RandomUtil.getArrayValue()` method to select a random ammo item template ID.
- Finished up some tests.
2023-11-07 22:59:04 -05:00
Refringe
3ba9e48a3e
Updates TimeUtil Class
- Adds the `date-fns-tz` module to dep.
- Moves the `date-fns` module from development dependancies to dependancies.
- Removes the depreciated `substr` method usage.
- Adds the `pad` method to handle padding time digits.
- Dates and times are now standardized UTC.
- Adds basic tests for all methods.
2023-11-07 21:32:57 -05:00
Dev
262c8a6e83 Add tests for getRandomCompatibleCaliberTemplateId() 2023-11-07 22:21:48 +00:00
Dev
c90f9499b1 Add more itemHelper tests 2023-11-07 21:52:41 +00:00
Dev
64845bf8ff Update tests 2023-11-07 21:30:29 +00:00
Refringe
a97c2b31ea
Testing performance improvements? I think so! 2023-11-07 15:42:32 -05:00
Refringe
65202b2aff
Remove the resetAllMocks call because restoreAllMocks does the same thing, plus restores the mocked method's original functionality. 2023-11-06 15:35:46 -05:00
Refringe
a7d3e0d59a
Tests: Moves class (re)resolution to beforeEach to help ensure that all mocks have been reset. 2023-11-06 14:39:12 -05:00
Dev
71312c8ed7 Disable prepareAndGenerateBotstest, add generateBotNickname tests 2023-11-06 17:23:33 +00:00
Dev
54223f3848 Add botController test 2023-11-05 20:11:52 +00:00
TheSparta
1f0318e66d Create container once before all tests
- Doesn't recreate the container for each test file, only loads the database once at the start, makes it much faster.
- Every test file should be imported in `Setup.test.ts` in order for it to work.
2023-11-05 16:59:54 +00:00
Dev
6f11e3de34 Add ItemBaseClassService tests 2023-11-05 16:44:08 +00:00
Dev
c12819ce33 Check for correct return type 2023-11-05 12:40:50 +00:00
Dev
d1614b19a6 Add tests for InRaidHelper 2023-11-05 10:49:20 +00:00
Dev
d4f2139236 Add additional tests to ItemHelper.test 2023-11-05 10:19:00 +00:00
Dev
ed20707935 Add tests for BotLevelGenerator 2023-11-05 09:20:11 +00:00
Dev
69b32fabdf Add HandbookHelper tests 2023-11-04 19:42:07 +00:00
TheSparta
45dad54e3e Fixed PlayerService.calculateLevel 2023-11-04 14:53:08 +00:00
Dev
6ca19150bc Add BotHelper tests 2023-11-04 13:34:09 +00:00
Dev
85b815f32e Add tests for PlayerServer.calculateLevel() 2023-11-04 11:43:04 +00:00
Dev
ebe7dc68c3 Add isInStash() tests to PaymentService.tests 2023-11-04 11:22:07 +00:00
Dev
b303849ad1 Add 3 test for getItemStackSize() 2023-11-04 10:21:56 +00:00
Dev
2f7f8a3f62 use correct base type id for test 2023-11-04 09:53:30 +00:00
Refringe
047884e9c7
Additional InsuranceController Tests
- Adds tests for the remaining methods in the `InsuranceController`.
- Adds a `countAllInsuranceItems()` method to the `InsuranceController`.
- Adds the Vitest UI and coverage packages.
- Updates the `profileInsuranceFactory` to use second-epoch dates instead of millisecond-epoch dates.
- Updates the `InsuranceController.fetchHideoutItemParent()` method to log a warning when an item with a slotId of 'hideout' cannot be found.

TODO:
- The Vitest coverage options are not working.
2023-11-03 17:39:33 -04:00
TheSparta
e327df7504 Override WinstonLogger registration with a mock 2023-11-02 15:58:16 +00:00
Refringe
85a227e7d5
Updates 🚀
- Created profileInsurance test fixture.
- Created ProfileInsurance test factory class.
- Improved many of the InsuranceController method tests by utilizing the factory and fixture. Still some left to do here.
- Adds the `date-fns` package as a development dependancy for easy date manipulation.
- Cleaned up some comments.

Bug Fixes 🐞
- Resolved an issue where `ItemHelper.getAttachmentMainParent()` was not returning null when it should have.
- Resolved an issue where `InsuranceController.populateParentAttachmentsMap()` would continue to process when the parent could not be found.
2023-11-02 01:47:28 -04:00
Refringe
7f37d48753
InsuranceController Tests & Minor Changes
- Adds tests for the majority of the methods within InsuranceController.
- Simplifies the `InsuranceController.sendMail()` method so that the toDelete parameter is no longer required.
- Modifies `InsuranceController.findItemsToDelete()` to only process regular and attachment items when they exist.
- Modifies `InsuranceController.rollForDelete()` to return null in the event that the provided Trader can not be found.
2023-10-31 23:08:13 -04:00
Refringe
1d90a472f2
Testing PaymentService.payMoney
Adds a single test for the basic functionality of the `PaymentService.payMoney` method. It's huge. I hate it. It works. The entire class needs to be refactored to be more testable. Each of these methods should be split up to only have (ideally) a single responsibility--It has about 6 going on right now.
2023-10-30 17:45:17 -04:00
Refringe
d85e649511
Removes Testing Profile/Account Creation
It was just too damn slow... 25+ seconds for *two*. Profile information will have to be partial-mocked using the sections and properties that the tested method will use, and casted as the parameter type (`IPmcData`, for example).
2023-10-30 17:38:37 -04:00
Refringe
1821607866
Moved import under database comment. 2023-10-30 11:46:40 -04:00
Refringe
f5c379e189
Mocks some logger methods to prevent actual execution. 2023-10-30 11:46:10 -04:00
Refringe
4e33befaa0
Creates a temporary testing account and profile for each test suite. This is really slow... May have to think this one through. 2023-10-29 22:21:21 -04:00
TheSparta
b31a48066b Removed usage of global.container
Importing container from tsyringe directly seems to work fine.
2023-10-29 22:20:35 +00:00
TheSparta
ba32350751 Refactored tests CustomEnvironment.
- Instead of importing everything and registering to the container, it now uses `@spt-aki/di/Container` instead.
2023-10-29 22:20:34 +00:00
Refringe
ad5e0815b6 Migrated from Jest to Vitest
Basically the same, except it plays nicer with Typescript and ESM.

I have it mostly working, except for a type error:
`TypeError: Int32Array is not a constructor`

But I'm too damn tired it debug it at the moment.
2023-10-29 22:20:32 +00:00
Refringe
00ac9e190a Additional Tests & New Setup
- Adds additional ItemHelper tests
- Attempts to bring container registration into the environment to debug how we can register everything but not actually start the server.
2023-10-29 22:20:32 +00:00
Refringe
f009d13d2a Successfully importing database and passing global container. 2023-10-29 22:20:31 +00:00
TheSparta
1eceb797e2 fixed tests tsyringe resolve 2023-10-29 22:20:30 +00:00
TheSparta
abbd60d7e2 Switched from ts-jest to @swc/jest 2023-10-29 22:20:30 +00:00
Refringe
ca0547ed1a Trying to get the @spt-aki path alias working in a custom Jest Env. 2023-10-29 22:20:29 +00:00
chomp
0b67a9a0e9 0.13.5.0 (!147)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-authored-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <e>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/147
2023-10-10 11:03:20 +00:00