This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
-
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.
- Loading branch information
1 parent
7d9988e
commit 6065e02
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
export function notEmptyString(data) { | ||
console.log("data=", data); | ||
|
||
if (data === undefined || data == null) { | ||
return false; | ||
} | ||
|
||
if (data == "") { | ||
return false; | ||
} | ||
|
||
const spaceRegix = /^ +$/; | ||
|
||
if (spaceRegix.test(data)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
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,29 @@ | ||
const expect = require("chai").expect; | ||
const notEmptyString = require("../src/utils/ValidationUtils").notEmptyString; | ||
|
||
|
||
describe('notEmptyString', () => { | ||
it('should notEmptyString with notEmptyString return true', () => { | ||
expect( | ||
notEmptyString("a") | ||
).to.equal(true); | ||
}); | ||
|
||
it('should notEmptyString with emptyString return false', () => { | ||
expect( | ||
notEmptyString("") | ||
).to.equal(false); | ||
}); | ||
|
||
it('should notEmptyString with undefined return false', () => { | ||
expect( | ||
notEmptyString(undefined) | ||
).to.equal(false); | ||
}); | ||
|
||
it('should notEmptyString with onlySpace return false', () => { | ||
expect( | ||
notEmptyString(" ") | ||
).to.equal(false); | ||
}); | ||
}); |