-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(StyleClassHelper): add putIfPresent method
- Loading branch information
1 parent
97158a3
commit f955a32
Showing
2 changed files
with
51 additions
and
8 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,31 @@ | ||
import { StyleClassHelper } from './StyleClassHelper'; | ||
|
||
describe('StyleClassHelper', () => { | ||
test('add class names', () => { | ||
const helper = StyleClassHelper.of('class1', 'class2'); | ||
expect(helper.className).toEqual(`class1 class2`); | ||
}); | ||
|
||
test('put new classes', () => { | ||
const helper = StyleClassHelper.of('firstClass'); | ||
helper.put('secondClass'); | ||
expect(helper.className).toEqual(`firstClass secondClass`); | ||
}); | ||
|
||
test('putIfPresent', () => { | ||
const helper = StyleClassHelper.of('firstClass'); | ||
helper.put('secondClass'); | ||
helper.putIfPresent('ifPresent1'); | ||
helper.putIfPresent('ifPresent2', 'ifPresent3'); | ||
helper.putIfPresent(true === false && 'shouldNotBeThere1', 'a' === 'a' && 'ifPresent4'); | ||
|
||
expect(helper.className).toEqual('firstClass secondClass ifPresent1 ifPresent2 ifPresent3 ifPresent4'); | ||
}); | ||
|
||
test('className, toString and valueOf return same value', () => { | ||
const helper = StyleClassHelper.of('class1', 'class2'); | ||
expect(helper.toString()).toEqual(`class1 class2`); | ||
expect(helper.valueOf()).toEqual(`class1 class2`); | ||
expect(helper.className).toEqual(`class1 class2`); | ||
}); | ||
}); |
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