harmonyc 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,12 @@ export class VitestGenerator {
15
15
  const fn = (this.currentFeatureName = pascalCase(feature.name));
16
16
  this.phraseFns = new Map();
17
17
  if (this.framework === 'vitest') {
18
- this.tf.print(`import { describe, test, expect } from 'vitest';`);
18
+ this.tf.print(`import { describe, test, expect } from "vitest";`);
19
+ }
20
+ if (feature.tests.length === 0) {
21
+ this.tf.print('');
22
+ this.tf.print(`describe.todo(${str(feature.name)});`);
23
+ return;
19
24
  }
20
25
  this.tf.print(`import ${fn}Phrases from ${str(phrasesModule)};`);
21
26
  this.tf.print(``);
@@ -127,8 +132,6 @@ export class VitestGenerator {
127
132
  this.tf.print(`(context.task.meta.variables ??= {})[${str(action.variableName)}] = ${action.value.toCode(this)};`);
128
133
  }
129
134
  saveToVariable(s, what = this.extraArgs[0] + ';') {
130
- if (this.extraArgs.length !== 1)
131
- return;
132
135
  this.tf.print(`(context.task.meta.variables ??= {})[${str(s.variableName)}] = ${what}`.trimEnd());
133
136
  }
134
137
  stringLiteral(text, { withVariables }) {
@@ -0,0 +1,27 @@
1
+ import { expect } from 'vitest';
2
+ export class TestPhrases {
3
+ constructor(context) {
4
+ this.context = context;
5
+ }
6
+ When_goodbye() {
7
+ throw new Error('Goodbye, World!');
8
+ }
9
+ When_hello() {
10
+ return (this.context.task.meta.greeting = 'Hello!');
11
+ }
12
+ When_greet_(name) {
13
+ this.context.task.meta.greeting = `Hello, ${name}!`;
14
+ }
15
+ async Then__is_(x, y) {
16
+ expect(x).toBe(y);
17
+ }
18
+ Then_last_char(s) {
19
+ return s.slice(-1);
20
+ }
21
+ Then_last_char_of_greeting() {
22
+ return this.context.task.meta.greeting.slice(-1);
23
+ }
24
+ Then_(s, r) {
25
+ expect(s).toBe(r);
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harmonyc",
3
3
  "description": "Harmony Code - model-driven BDD for Vitest",
4
- "version": "0.12.1",
4
+ "version": "0.13.0",
5
5
  "author": "Bernát Kalló",
6
6
  "type": "module",
7
7
  "bin": {