Skip to content
Snippets Groups Projects

unit_test_refactor

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Alex P

    In a current functions implementation it would be tricky to work with dependencies. What we can do in order to simplify the setup is to use this as a dependency source.

    There are two ways of doing that: via context binding and object method context:

    Context binding gives us possibility to use private state and private functions, we have the same functions expressions, so no need to rewrite it's usage. While object method context is simpler and have less boilerplate.

    Edited
    context_bind.ts 1.56 KiB
    no_refactor_unit_tests.ts 3.13 KiB
    object.ts 1.43 KiB
    original_file.ts 1.07 KiB
    unit_test_for_context_binding.ts 2.07 KiB
    unit_test_for_object_method.ts 1.93 KiB
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment