Skip to content

Commit

Permalink
chore: add-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbas21 committed Feb 6, 2025
1 parent 31d6c10 commit ae474d2
Showing 1 changed file with 168 additions and 11 deletions.
179 changes: 168 additions & 11 deletions packages/davinci-client/src/lib/node.reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,63 @@ describe('The node collector reducer', () => {
it('should handle next node with one field', () => {
const action = {
type: 'node/next',
payload: [
{
payload: {
fields: [
{
key: 'username',
type: 'TEXT',
label: 'Username',
},
],
formData: {},
},
};
expect(nodeCollectorReducer(undefined, action)).toEqual([
{
category: 'SingleValueCollector',
error: null,
type: 'TextCollector',
id: 'username-0',
name: 'username',
input: {
key: 'username',
value: '',
type: 'TEXT',
},
output: {
key: 'username',
label: 'Username',
type: 'TEXT',
value: '',
},
],
},
]);
});
it('should NOT populate the formData with input information for password collector', () => {
const action = {
type: 'node/next',
payload: {
fields: [
{
key: 'username',
type: 'TEXT',
label: 'Username',
},
{
key: 'password',
type: 'PASSWORD',
label: 'Password',
},
{
key: 'submit',
type: 'SUBMIT_BUTTON',
label: 'Submit',
},
],
formData: {
password: 'SUPERSECRETPASSWORD',
},
},
};
expect(nodeCollectorReducer(undefined, action)).toEqual([
{
Expand All @@ -39,29 +89,136 @@ describe('The node collector reducer', () => {
value: '',
},
},
{
category: 'SingleValueCollector',
error: null,
type: 'PasswordCollector',
id: 'password-1',
name: 'password',
input: {
key: 'password',
value: '',
type: 'PASSWORD',
},
output: {
key: 'password',
label: 'Password',
type: 'PASSWORD',
},
},
{
category: 'ActionCollector',
error: null,
type: 'SubmitCollector',
id: 'submit-2',
name: 'submit',
output: {
key: 'submit',
label: 'Submit',
type: 'SUBMIT_BUTTON',
},
},
]);
});

it('should handle next node with multiple fields', () => {
it('should populate the formData with input information', () => {
const action = {
type: 'node/next',
payload: [
{
payload: {
fields: [
{
key: 'username',
type: 'TEXT',
label: 'Username',
},
{
key: 'password',
type: 'PASSWORD',
label: 'Password',
},
{
key: 'submit',
type: 'SUBMIT_BUTTON',
label: 'Submit',
},
],
formData: {
username: 'This is the default data',
},
},
};
expect(nodeCollectorReducer(undefined, action)).toEqual([
{
category: 'SingleValueCollector',
error: null,
type: 'TextCollector',
id: 'username-0',
name: 'username',
input: {
key: 'username',
value: '',
type: 'TEXT',
},
output: {
key: 'username',
label: 'Username',
type: 'TEXT',
value: 'This is the default data',
},
{
},
{
category: 'SingleValueCollector',
error: null,
type: 'PasswordCollector',
id: 'password-1',
name: 'password',
input: {
key: 'password',
value: '',
type: 'PASSWORD',
},
output: {
key: 'password',
label: 'Password',
type: 'PASSWORD',
},
{
},
{
category: 'ActionCollector',
error: null,
type: 'SubmitCollector',
id: 'submit-2',
name: 'submit',
output: {
key: 'submit',
type: 'SUBMIT_BUTTON',
label: 'Submit',
type: 'SUBMIT_BUTTON',
},
],
},
]);
});
it('should handle next node with multiple fields', () => {
const action = {
type: 'node/next',
payload: {
fields: [
{
key: 'username',
type: 'TEXT',
label: 'Username',
},
{
key: 'password',
type: 'PASSWORD',
label: 'Password',
},
{
key: 'submit',
type: 'SUBMIT_BUTTON',
label: 'Submit',
},
],
formData: {},
},
};
expect(nodeCollectorReducer(undefined, action)).toEqual([
{
Expand Down

0 comments on commit ae474d2

Please sign in to comment.