test: add deprecation code to expectWarning
This commit adds a deprecation code to expectWarning and updates the function to check the passed code against the code property on the warning object.
Not all warnings have a deprecation code so for those that don't an explicit code of common.noWarnCode is required. Passing this skips the assertion of the code.
This PR follows up on https://github.com/nodejs/node/pull/19317.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
documentation is changed or added -
commit message follows commit guidelines