Skip to content
Permalink
Browse files
fix(core): Ensure tags are reported in a format understood by Serenit…
…y BDD
  • Loading branch information
jan-molak committed Mar 31, 2019
1 parent f243613 commit 6c4315cb49204e3cf589205c329ee9ba87f64568
@@ -33,7 +33,7 @@ describe('@serenity-js/cucumber', function() {
expect(res.exitCode).to.equal(0);

PickEvent.from(res.events)
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example_capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises capabilities')))
;
}));
@@ -33,8 +33,8 @@ describe('@serenity-js/cucumber', function() {
expect(res.exitCode).to.equal(0);

PickEvent.from(res.events)
.next(SceneTagged, event => expect(event.tag).to.equal(new ThemeTag('example theme')))
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new ThemeTag('example_theme')))
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example_capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises capabilities and themes')))
;
}));
@@ -1,4 +1,4 @@
import { TinyType, TinyTypeOf } from 'tiny-types';
import { TinyType } from 'tiny-types';

/** @access package */
export class IDGenerator {
@@ -93,7 +93,14 @@ export class SceneReport {

taggedWith(tag: Tag) {
return this.withMutated(report => {
const nameOfRecorded = (typeOfTag: { Type: string }) => (report.tags.find(t => t.type === typeOfTag.Type) || { name: void 0 }).name;
function nameOfRecorded(typeOfTag: { Type: string }) {
const serenityBDDCompatible = (text: string) => text[0].toUpperCase() + text.slice(1);

const found = report.tags.find(t => t.type === typeOfTag.Type);

return found && serenityBDDCompatible(found.name);
}

const concatenated = (...names: string[]): string => names.filter(name => !! name).join('/');

const serialisedTag = tag.toJSON();
@@ -106,8 +106,6 @@ export class Notifier {
}

private scenarioHierarchyTagsFor(feature: Feature): Tag[] {
const humanReadable = (text: string) => text.replace(/[_-]+/g, ' ');

const
directories = notEmpty(feature.location.path.directory().split()),
featuresIndex = directories.indexOf('features'),
@@ -116,8 +114,8 @@ export class Notifier {
const [ featureName, capabilityName, themeName ]: string[] = hierarchy.reverse();

return notEmpty([
themeName && new ThemeTag(humanReadable(themeName)),
capabilityName && new CapabilityTag(humanReadable(capabilityName)),
themeName && new ThemeTag(themeName),
capabilityName && new CapabilityTag(capabilityName),
feature && new FeatureTag(featureName),
]);
}

0 comments on commit 6c4315c

Please sign in to comment.