Skip to content

Commit

Permalink
Fix #360 - Enum cases using wrong separator in switch statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dangmai committed Apr 26, 2021
1 parent 038a74f commit 041bc4a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.9.1

- Fix Enum cases using wrong separator in `switch` statements ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/360)).

# 1.9.0

## Dependency Changes
Expand Down
2 changes: 1 addition & 1 deletion src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ function handleTypeWhen(path, print) {
}

function handleEnumCase(path, print) {
return join(",", path.map(print, "identifiers"));
return join(".", path.map(print, "identifiers"));
}

function handleRunAsBlock(path, print) {
Expand Down
6 changes: 6 additions & 0 deletions tests/switch/SwitchClass.cls
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class SwitchClass {
}

switch on randomObject {
when EmumVariable.CaseOne {
System.debug('Object');
}
when EmumVariable.CaseTwo, EnumVariable.CaseTwo {
System.debug('Object');
}
when Account a {
System.debug('Account ' + a);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/switch/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class SwitchClass {
}
switch on randomObject {
when EmumVariable.CaseOne {
System.debug('Object');
}
when EmumVariable.CaseTwo, EnumVariable.CaseTwo {
System.debug('Object');
}
when Account a {
System.debug('Account ' + a);
}
Expand Down Expand Up @@ -139,6 +145,12 @@ class SwitchClass {
}
switch on randomObject {
when EmumVariable.CaseOne {
System.debug('Object');
}
when EmumVariable.CaseTwo, EnumVariable.CaseTwo {
System.debug('Object');
}
when Account a {
System.debug('Account ' + a);
}
Expand Down

0 comments on commit 041bc4a

Please sign in to comment.