-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix delete draft voucher code on voucher create page (#5104)
* Fix delete draft voucher code on voucher create page * Add changeset * Fix import --------- Co-authored-by: Patryk Andrzejewski <[email protected]>
- Loading branch information
1 parent
9434aea
commit 6289fbd
Showing
6 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
You can now delete draft voucher codes during creation of new voucher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
generateDraftVoucherCode, | ||
generateMultipleVoucherCodes, | ||
} from "@dashboard/discounts/components/VoucherCreatePage/utils"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
|
||
jest.mock("uuid"); | ||
|
||
describe("generateDraftVoucherCode", () => { | ||
it("should return draft voucher code", () => { | ||
// Act | ||
const draftVoucherCode = generateDraftVoucherCode("test1"); | ||
|
||
// Assert | ||
expect(draftVoucherCode).toEqual({ | ||
code: "test1", | ||
status: "Draft", | ||
}); | ||
}); | ||
}); | ||
|
||
describe("generateMultipleVoucherCodes", () => { | ||
it("should return multiple voucher codes", () => { | ||
// Arrange | ||
(uuidv4 as jest.Mock).mockImplementation(() => "uuid"); | ||
|
||
// Act | ||
const draftVoucherCodes = generateMultipleVoucherCodes("2", "test"); | ||
|
||
// Assert | ||
expect(draftVoucherCodes).toEqual([ | ||
{ code: "test-uuid", status: "Draft" }, | ||
{ code: "test-uuid", status: "Draft" }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters