-
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.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/attributes/components/AttributeValueEditDialog/utils.test.ts
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,54 @@ | ||
import { AttributeValueEditDialogFormData } from "@dashboard/attributes/utils/data"; | ||
|
||
import { getAttributeValueFields } from "./utils"; | ||
|
||
describe("getAttributeValueFields", () => { | ||
it("should return fileUrl and contentType if attributeValue has fileUrl", () => { | ||
// Arrange | ||
const attributeValue = { | ||
fileUrl: "fileUrl", | ||
contentType: "contentType", | ||
value: "value", | ||
} as AttributeValueEditDialogFormData; | ||
const isSwatch = true; | ||
|
||
// Act | ||
const result = getAttributeValueFields(attributeValue, isSwatch); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
fileUrl: "fileUrl", | ||
contentType: "contentType", | ||
}); | ||
}); | ||
|
||
it("should return value when attributeValue has value and is swatch type", () => { | ||
// Arrange | ||
const attributeValue = { | ||
value: "value", | ||
} as AttributeValueEditDialogFormData; | ||
const isSwatch = true; | ||
|
||
// Act | ||
const result = getAttributeValueFields(attributeValue, isSwatch); | ||
|
||
// Assert | ||
expect(result).toEqual({ | ||
value: "value", | ||
}); | ||
}); | ||
|
||
it("should return empty object when attributeValue has value but type is not swatch", () => { | ||
// Arrange | ||
const attributeValue = { | ||
value: "value", | ||
} as AttributeValueEditDialogFormData; | ||
const isSwatch = false; | ||
|
||
// Act | ||
const result = getAttributeValueFields(attributeValue, isSwatch); | ||
|
||
// Assert | ||
expect(result).toEqual({}); | ||
}); | ||
}); |
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