|
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(); |
2 | 7 |
|
3 | 8 | describe('logicAspect() tests', () => {
|
4 | 9 |
|
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 | + |
8 | 111 | });
|
9 | 112 |
|
10 | 113 | });
|
0 commit comments