Skip to content

Commit 3652ac4

Browse files
committed
shoring up test coverage
1 parent 730d6ec commit 3652ac4

File tree

2 files changed

+108
-4
lines changed

2 files changed

+108
-4
lines changed

src/logicAspect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {createLogicMiddleware} from 'redux-logic'; // peerDependency
22
import {createAspect,
3+
extendAspectProperty,
34
launchApp} from 'feature-u'; // peerDependency:
45

56
// our logger (integrated/activated via feature-u)

src/spec/logicAspect.spec.js

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,113 @@
1-
import {logicAspect} from '..'; // STOP USING: '../../tooling/ModuleUnderTest';
1+
import {launchApp, // ?? just needed while our logs are on
2+
createFeature} from 'feature-u';
3+
import {logicAspect} from '..'; // modules under test
4+
5+
// temporarly turn on logging (just for fun)
6+
// launchApp.diag.logf.enable();
27

38
describe('logicAspect() tests', () => {
49

5-
test('name', () => {
6-
expect( logicAspect.name)
7-
.toEqual('logic');
10+
describe('validate logicAspect.name', () => {
11+
12+
test('name', () => {
13+
expect( logicAspect.name)
14+
.toBe('logic');
15+
});
16+
17+
});
18+
19+
20+
describe('genesis()', () => {
21+
22+
logicAspect.genesis();
23+
24+
const noOpTest = "can't access isAspectProperty() ... just running code :-(";
25+
test('verify extendAspectProperty()', () => {
26+
expect(noOpTest)
27+
.toBe(noOpTest);
28+
});
29+
30+
});
31+
32+
33+
describe('validateFeatureContent()', () => {
34+
35+
test('must be an array', () => {
36+
37+
const feature = createFeature({
38+
name: 'feature1',
39+
logic: "I'm NOT an array",
40+
})
41+
42+
expect(logicAspect.validateFeatureContent(feature))
43+
.toMatch(/must be an array/);
44+
});
45+
46+
test('success', () => {
47+
48+
const feature = createFeature({
49+
name: 'feature1',
50+
logic: ['mock', 'logic', 'modules'],
51+
})
52+
53+
expect(logicAspect.validateFeatureContent(feature))
54+
.toBe(null);
55+
});
56+
57+
});
58+
59+
60+
describe('assembleFeatureContent()', () => {
61+
62+
test('no logic modules (DEFAULT)', () => {
63+
expect(()=>logicAspect.assembleFeatureContent('simulated app', []))
64+
.toThrow(/found NO logic modules within your features/);
65+
});
66+
67+
describe('no logic modules (OVERRIDE true)', () => {
68+
beforeEach(() => {
69+
logicAspect.allowNoLogic$ = true;
70+
});
71+
afterEach(() => {
72+
logicAspect.allowNoLogic$ = false;
73+
});
74+
test('expecting getReduxMiddleware() to be null', () => {
75+
logicAspect.assembleFeatureContent('simulated app', []);
76+
expect(logicAspect.getReduxMiddleware())
77+
.toBe(null);
78+
});
79+
});
80+
81+
describe('no logic modules (OVERRIDE array)', () => {
82+
beforeEach(() => {
83+
logicAspect.allowNoLogic$ = ['simulated', 'logic'];
84+
});
85+
afterEach(() => {
86+
logicAspect.allowNoLogic$ = false;
87+
});
88+
test('expecting getReduxMiddleware() to be non-null', () => {
89+
logicAspect.assembleFeatureContent('simulated app', []);
90+
expect(logicAspect.getReduxMiddleware())
91+
.not.toBe(null);
92+
});
93+
});
94+
95+
describe('features have logic modules', () => {
96+
test('expecting getReduxMiddleware() to be non-null', () => {
97+
logicAspect.assembleFeatureContent('simulated app', [
98+
createFeature({
99+
name: 'feature1',
100+
logic: ['simulated', 'logic']
101+
}),
102+
createFeature({
103+
name: 'featureWithNoLogic',
104+
})
105+
]);
106+
expect(logicAspect.getReduxMiddleware())
107+
.not.toBe(null);
108+
});
109+
});
110+
8111
});
9112

10113
});

0 commit comments

Comments
 (0)