-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got Experiences Working and added some validation
- Loading branch information
1 parent
acc84a4
commit 4bc7ca6
Showing
4 changed files
with
163 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { expect } from 'chai'; | ||
import { FlowChannel, FlowScheduleType, FlowStatus, FlowType, IFlowDefinition } from '../models'; | ||
import { CreateExperienceSchema } from './flowSchema'; | ||
|
||
describe('Flow Experience Input Schema', () => { | ||
let experienceDefinition: IFlowDefinition; | ||
|
||
beforeEach(() => { | ||
// Initialize the base experience definition before each test | ||
experienceDefinition = { | ||
name: 'Test API Experience', | ||
friendlyId: 'test_api_experience', | ||
type: FlowType.WebFlow, | ||
channels: [FlowChannel.Web], | ||
status: FlowStatus.Draft, | ||
schedule: { | ||
type: FlowScheduleType.Simple, | ||
startDate: new Date().toISOString(), | ||
}, | ||
}; | ||
}); | ||
|
||
it('should return false for bad friendly id', () => { | ||
experienceDefinition.friendlyId = 'test-api-experience'; // Invalid friendlyId | ||
|
||
const validationResult = CreateExperienceSchema.safeParse(experienceDefinition); | ||
|
||
expect(validationResult.success).to.be.equal(false); | ||
}); | ||
|
||
it('should return true for valid friendly id', () => { | ||
experienceDefinition.friendlyId = 'test_api_experience'; // Valid friendlyId | ||
|
||
const validationResult = CreateExperienceSchema.safeParse(experienceDefinition); | ||
|
||
expect(validationResult.success).to.be.equal(true); | ||
}); | ||
|
||
it('should return false for missing name', () => { | ||
delete experienceDefinition.name; // Missing name | ||
|
||
const validationResult = CreateExperienceSchema.safeParse(experienceDefinition); | ||
|
||
expect(validationResult.success).to.be.equal(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
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