If you’re writing a simple service that has no dependencies on other components or the application object, then you can use the following basic formats for your tests.
Testing Services with Dependencies
If your service depends on the application object to perform its tasks, then you’ll need to stub it out. To do so, create a new instance of Box.TestServiceProvider (from the testing bundle.
To create a true unit test, you need to create a stub for each service that your code depends on. This example creates a stub service called “another-service”. The call to new Box.TestServiceProvider() includes a name-value list of service names and objects that should be returned for that name. The returned object is then passed in as the second argument to Box.Application.getServiceForTest() so that it becomes available inside of the service creator function.