ZINC-FYP-2022-23 / console

ZINC UI for teaching assistants
1 stars 0 forks source link

test(gui): use mock functions in config.test.ts #17

Closed AnsonH closed 2 years ago

AnsonH commented 2 years ago

Description

In utils/Config/__tests__/config.test.ts, we performed "integration" tests to make sure an entire YAML can be serialized, and an entire Config instance can be de-serialized to YAML.

For example, in the test for configToYaml(), we directly test if a Config object can serialize to an expected YAML string.

This is not optimal because configToYaml() calls settingsToYamlObj() internally (a dependency of configToYaml()), such that if settingsToYamlObj() is implemented incorrectly, then that test case must fail.

Solution

We should mock the dependency utility functions (e.g. settingsToYamlObj() in configToYaml()) to test that they have been invoked.