-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema): update component can get and sku but not both
- Loading branch information
Showing
6 changed files
with
6,021 additions
and
6,783 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
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
83 changes: 83 additions & 0 deletions
83
components/schema/tests/mass-operation/update-component.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,83 @@ | ||
import { never, ZodError } from 'zod'; | ||
import { UpdateCompomentOperation, UpdateCompomentOperationSchema } from '../../src/mass-operation/item'; | ||
import { describe, expect, it, test } from 'vitest'; | ||
|
||
describe('Mass Operations - Update Component Operation', {}, async () => { | ||
it('should NOT fail if the component is valid with only itemId ', () => { | ||
const updateComponentOperation: UpdateCompomentOperation = { | ||
action: 'updateComponent', | ||
concern: 'item', | ||
itemId: '604f7655a16b91dea030895b', | ||
language: 'en', | ||
component: { | ||
componentId: '456', | ||
boolean: { | ||
value: true, | ||
}, | ||
}, | ||
}; | ||
expect(UpdateCompomentOperationSchema.safeParse(updateComponentOperation)).toEqual({ | ||
success: true, | ||
data: updateComponentOperation, | ||
}); | ||
}); | ||
|
||
it('should NOT fail if the component is valid with only sku ', () => { | ||
const updateComponentOperation: UpdateCompomentOperation = { | ||
action: 'updateComponent', | ||
concern: 'item', | ||
language: 'en', | ||
sku: 'asdasd', | ||
component: { | ||
componentId: '456', | ||
boolean: { | ||
value: true, | ||
}, | ||
}, | ||
}; | ||
expect(UpdateCompomentOperationSchema.safeParse(updateComponentOperation)).toEqual({ | ||
success: true, | ||
data: updateComponentOperation, | ||
}); | ||
}); | ||
|
||
it('should fail if the component contains sku and itemId ', () => { | ||
// @ts-expect-error | ||
const updateComponentOperation: UpdateCompomentOperation = { | ||
action: 'updateComponent', | ||
concern: 'item', | ||
language: 'en', | ||
sku: 'asdasd', | ||
itemId: '604f7655a16b91dea030895b', | ||
component: { | ||
componentId: '456', | ||
boolean: { | ||
value: true, | ||
}, | ||
}, | ||
}; | ||
expect(UpdateCompomentOperationSchema.safeParse(updateComponentOperation)).toMatchObject({ | ||
success: false, | ||
}); | ||
}); | ||
|
||
it('should fail if the component is invalid ', () => { | ||
// @ts-expect-error | ||
const updateComponentOperation: UpdateCompomentOperation = { | ||
action: 'updateComponent', | ||
concern: 'item', | ||
language: 'en', | ||
sku: 'asdasd', | ||
itemId: '604f655a16b91dea030895b', // mistake here | ||
component: { | ||
componentId: '456', | ||
boolean: { | ||
value: true, | ||
}, | ||
}, | ||
}; | ||
expect(UpdateCompomentOperationSchema.safeParse(updateComponentOperation)).toMatchObject({ | ||
success: false, | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
], | ||
"devDependencies": { | ||
"prettier": "3.3.2", | ||
"turbo": "^2.0.6" | ||
"turbo": "^2.3.0" | ||
}, | ||
"scripts": { | ||
"build": "turbo run build", | ||
|
@@ -19,6 +19,5 @@ | |
"packageManager": "[email protected]", | ||
"volta": { | ||
"node": "20.15.0" | ||
}, | ||
"dependencies": {} | ||
} | ||
} |
Oops, something went wrong.