Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return false if value is empty string', () => {
expect(required('')).toEqual(false);
});
it('should return false if value is null', () => {
expect(required(null)).toEqual(false);
});
it('should return true if value is boolean', () => {
expect(required(true)).toEqual(true);
expect(required(false)).toEqual(true);
});
it('should return true if value is non-empty string', () => {
expect(required('example')).toEqual(true);
});
it('should return true if array is not empty', () => {
expect(required(['a', 'b'])).toEqual(true);
});
});
it('should return false if value is undefined', () => {
expect(required(undefined)).toEqual(false);
});
it('should return false if value is blank string', () => {
expect(required(' ')).toEqual(false);
});
it('should return true if value is boolean', () => {
expect(required(true)).toEqual(true);
expect(required(false)).toEqual(true);
});