ft-${fileName}: replace me
`;
}
/**
* source for reducer
* @param funcName, fileName
*/
generateReducerJsSource(funcName, fileName) {
return `/**
* Data Reducer for ${funcName}
* Takes site specific json data and creates model for components
* after applying business and presentation logic and data mapping
*/
import {LogManager} from 'aurelia-framework';
const logger = LogManager.getLogger('${fileName}');
export function ${funcName}(state, action) {
switch (action.type) {
case 'CHANGE_ME_TO_PROPER_ACTION_NAME_SUCCESS':
logger.debug('Reducing: CHANGE_ME_TO_PROPER_ACTION_NAME_SUCCESS');
return Object.assign({}, state, {
${funcName}: action.data
});
default:
return state;
}
}
`;
}
/**
* source for reducer unit test
* @param funcName
*/
generateReducerTestJsSource(funcName, fileName) {
return `import {${funcName}} from './${fileName}.reducer';
describe('${funcName}', () => {
it('should return unchanged state if action does not apply', done => {
let action = {
type: 'ANOTHER_ACTION'
};
let oldState = {};
let newState = ${funcName}(oldState, action, {});
expect(newState).toBe(oldState);
done();
});
it('should return some stuff', done => {
let action = {
type: 'CHANGE_ME_TO_PROPER_ACTION_NAME_SUCCESS',
data: {
stuff: 'some stuff'
}
};
let newState = ${funcName}({}, action, {});
expect(newState.${funcName}.stuff).toBe('some stuff');
done();
});
});
`;
}
/**
* source for reducer
* @param funcName, fileName
*/
generateAppStateReducerJsSource(funcName, fileName) {
return `/**
* App State Reducer for ${funcName}
* Takes application state data and creates model for components
*/
import {LogManager} from 'aurelia-framework';
const logger = LogManager.getLogger('${fileName}');
export function ${funcName}(state, action) {
switch (action.type) {
case 'SOME_ACTION':
logger.debug('Reducing: SOME_ACTION');
return Object.assign({}, state, {
${funcName}: action.data
});
default:
return state;
}
}
`;
}
/**
* source for reducer unit test
* @param funcName
*/
generateAppStateReducerTestJsSource(funcName, fileName) {
return `import {${funcName}} from './${fileName}.reducer';
describe('${funcName}', () => {
it('should return unchanged state if action does not apply', done => {
let action = {
type: 'ANOTHER_ACTION'
};
let oldState = {};
let newState = ${funcName}(oldState, action, {});
expect(newState).toBe(oldState);
done();
});
it('should return some stuff', done => {
let action = {
type: 'SOME_ACTION',
data: {
stuff: 'some stuff'
}
};
let newState = ${funcName}({}, action, {});
expect(newState.${funcName}.stuff).toBe('some stuff');
done();
});
});
`;
}
/**
* generate markdown stub
* @param fileName
* @returns {string}
*/
generateComponentMdSource(fileName) {
return `# ${ fileName }
## Usage
${'```'}html
<${ fileName} fund-id="817" cid="uniqueId">${ fileName}>
${'```'}
*The cid is guaranteed to be unique to this page even if multiple instances of the component are added to the same page.*
## Developer notes
`;
}
/**
* generate sass partial stub
* @param fileName
* @returns {string}
*/
generateComponentSassSource(fileName, name) {
return `
// CSS specific to the ${ fileName } component goes here
[data-fti-component="${ name }"] {
}
`;
}
}