Skip to content

Commit

Permalink
cleaned up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 committed Aug 24, 2020
1 parent d45a17b commit 6d22c28
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ interface Metadata {
/**
* A record of entityIDs to be used in tests assertions.
*/
entityIDs: {
/**
* The entityID of the node related to the document being analyzed.
*/
nonExisting: 'nonExisting';
};
entityIDs: {};
}

/**
Expand All @@ -35,8 +30,8 @@ export function noResolverDataReturned(): {
metadata: Metadata;
} {
const metadata: Metadata = {
databaseDocumentID: '_id',
entityIDs: { nonExisting: 'nonExisting' }, // TODO: pointless, but explicitly documents?
databaseDocumentID: '_noDataID',
entityIDs: {},
};
return {
metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ export class Simulator {
}

/**
* Find the graph container by document ID.
* Find the graph container by the database document ID.
* This better allows us to test when new data is loaded into an existing resolver
*/
public processResolverGraph(databaseDocumentID: string): ReactWrapper {
return this.domNodes(`[data-test-resolver-document-id="${databaseDocumentID}"]`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,40 @@ import { noAncestorsTwoChildren } from '../data_access_layer/mocks/no_ancestors_
import { noResolverDataReturned } from '../data_access_layer/mocks/no_resolver_data_returned';
import '../test_utilities/extend_jest';

describe('resolver: when data has been requested', () => {
describe('Resolver: data loading and resolution states', () => {
let simulator: Simulator;
const resolverComponentInstanceID = 'resolver-loading-state';
const newTreeId = 'new-tree-id';

describe('When resolver is loaded with data', () => {
beforeEach(() => {
const {
metadata: { databaseDocumentID },
dataAccessLayer,
} = noAncestorsTwoChildren();

simulator = new Simulator({
dataAccessLayer,
databaseDocumentID,
resolverComponentInstanceID,
});
});

it('should display the resolver graph', async () => {
await expect(
simulator.map(() => ({
resolverGraphLoading: simulator.testSubject('resolver:graph:loading').length,
resolverGraphError: simulator.testSubject('resolver:graph:error').length,
resolverGraph: simulator.testSubject('resolver:graph').length,
}))
).toYieldEqualTo({
resolverGraphLoading: 0,
resolverGraphError: 0,
resolverGraph: 1,
});
});
});

describe('When resolver data is being requested', () => {
beforeEach(() => {
const {
Expand All @@ -27,6 +56,7 @@ describe('resolver: when data has been requested', () => {
resolverComponentInstanceID,
});
});

it('should display a loading state', async () => {
// Trigger a loading state by requesting data based on a new DocumentID.
// There really is no way to do this in the view besides changing the url, so triggering the action instead
Expand Down

0 comments on commit 6d22c28

Please sign in to comment.