Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isValue into mappers #59

Closed
4 tasks done
Siemienik opened this issue Oct 20, 2020 · 0 comments · Fixed by #86
Closed
4 tasks done

Add isValue into mappers #59

Siemienik opened this issue Oct 20, 2020 · 0 comments · Fixed by #86
Labels
accepted It is accepted to do good first issue Good for newcomers

Comments

@Siemienik
Copy link
Owner

Siemienik commented Oct 20, 2020

Part of #21

TODO:

  1. Create file src/mappers/isValue.ts with function matches to type (...acceptedValues:string[]) => ValueMapper<boolean>. Which check value to be included in accepted values. Returns false if no accepted values provided.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  // without accepted values
  { inValue: '', inAcceptedValue:[], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:[], expectedResult: false },
  { inValue: 'X', inAcceptedValue:[], expectedResult: false },
  { inValue: '1', inAcceptedValue:[], expectedResult: false },
  { inValue: 'FALSE', inAcceptedValue:[], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:[], expectedResult: false },

  // with one accepted value
  { inValue: '', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'X', inAcceptedValue:['X'], expectedResult: true },
  { inValue: '1', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'FALSE', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:['X'], expectedResult: false },

  // with more than one accepted value
  { inValue: '', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: 'X', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: '1', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: 'FALSE', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },

  // with different case
  { inValue: 'TRUE', inAcceptedValue:['true'], expectedResult: true },
  { inValue: 'X', inAcceptedValue:['x'], expectedResult: true },
];

For making a reservation please open draft PR with this issue linked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted It is accepted to do good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant