I've been thinking about how to test particular functions used by other functions within the same file.

For example, say I have two functions within one file:

```
// validators.js
export const required = ...;
export const containsUppercase = ...;
export const containsNumber = ...;

export const password = (val) => [required, containsUppercase, containsNumber].every(f => f(val));

```

So clearly, the password validator depends on the `required`, `containsUppercase` and `containsNumber` functions. But what if I wanted to stub those out, so my tests didn't actually have to care about those functions or how they validate.

This is a simple, silly example, but I've ran into the same problem with more complex scenarios.

For example, if I try to do this with sinon, I might try doing this:

```
import * as validators from './validators';

sinon.stub(validators, 'required').returns(false);
sinon.stub(validators, 'containsUppercase').returns(true);
sinon.stub(validators, 'containsNumber').returns(true);

// test
expect(validators.password('notImportant')).toBe(false);

```

I tried doing this, but I couldn't get it to work. I found that I could get it to work, if I did something like this, though I haven't tested it.

```
const required = ...;
const containsUppercase = ...;
const containsNumber = ...;

const password = (val) => [ex.required, ex.containsUppercase, ex.containsNumber].every(f => f(val));

export default ex = {
  required,
  containsUppercase,
  containsNumber,
  password,
}

```

This solution is also ugly, since I now I'd have to worry about exporting the function in the right place, and also reference it through the export object.

Is there a cleaner way to do this? Or rather, what would be the best way to test these kinds of functions?