Add more and unify tests for absent object cases
- Unify test data for nonexistence of an object/string and collection. - Introduce more test through adding missing test data to existing tests. - Improve logic for checking absence of values to match tests. - Add missing tests for absent value validation. - Update documentation to include shared test functionality.
This commit is contained in:
@@ -8,6 +8,7 @@ import { IApplication } from '@/domain/IApplication';
|
||||
import { EnvironmentStub } from '@tests/unit/stubs/EnvironmentStub';
|
||||
import { ApplicationStub } from '@tests/unit/stubs/ApplicationStub';
|
||||
import { CategoryCollectionStub } from '@tests/unit/stubs/CategoryCollectionStub';
|
||||
import { expectThrowsAsync } from '@tests/unit/shared/Assertions/ExpectThrowsAsync';
|
||||
|
||||
describe('ApplicationContextFactory', () => {
|
||||
describe('buildContext', () => {
|
||||
@@ -23,6 +24,15 @@ describe('ApplicationContextFactory', () => {
|
||||
// assert
|
||||
expect(expected).to.equal(context.app);
|
||||
});
|
||||
it('throws when null', async () => {
|
||||
// arrange
|
||||
const expectedError = 'missing factory';
|
||||
const factory = null;
|
||||
// act
|
||||
const act = async () => { await buildContext(factory); };
|
||||
// assert
|
||||
expectThrowsAsync(act, expectedError);
|
||||
});
|
||||
});
|
||||
describe('environment', () => {
|
||||
describe('sets initial OS as expected', () => {
|
||||
@@ -69,6 +79,16 @@ describe('ApplicationContextFactory', () => {
|
||||
expect(expectedOs).to.equal(actual, `Expected: ${OperatingSystem[expectedOs]}, actual: ${OperatingSystem[actual]}`);
|
||||
});
|
||||
});
|
||||
it('throws when null', async () => {
|
||||
// arrange
|
||||
const expectedError = 'missing environment';
|
||||
const factory = mockFactoryWithApp(undefined);
|
||||
const environment = null;
|
||||
// act
|
||||
const act = async () => { await buildContext(factory, environment); };
|
||||
// assert
|
||||
expectThrowsAsync(act, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user