-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: complete stringfiedObject api
- Loading branch information
1 parent
afa64d9
commit 689f7fa
Showing
2 changed files
with
44 additions
and
4 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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
/** | ||
* @module edge | ||
*/ | ||
|
||
/* | ||
* edge | ||
* | ||
|
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,44 @@ | ||
/* | ||
* edge | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import test from 'japa' | ||
|
||
import { StringifiedObject } from '../src/StringifiedObject' | ||
|
||
test.group('StringifiedObject', () => { | ||
test('add string as a key-value pair to object', (assert) => { | ||
const stringified = new StringifiedObject() | ||
stringified.add('username', '\'virk\'') | ||
assert.equal(stringified.flush(), '{ username: \'virk\' }') | ||
}) | ||
|
||
test('add number as a key-value pair to object', (assert) => { | ||
const stringified = new StringifiedObject() | ||
stringified.add('username', '22') | ||
assert.equal(stringified.flush(), '{ username: 22 }') | ||
}) | ||
|
||
test('add boolean as a key-value pair to object', (assert) => { | ||
const stringified = new StringifiedObject() | ||
stringified.add('username', 'true') | ||
assert.equal(stringified.flush(), '{ username: true }') | ||
}) | ||
|
||
test('add object as a key-value pair to object', (assert) => { | ||
const stringified = new StringifiedObject() | ||
stringified.add('username', '{ age: 22 }') | ||
assert.equal(stringified.flush(), '{ username: { age: 22 } }') | ||
}) | ||
|
||
test('add array as a key-value pair to object', (assert) => { | ||
const stringified = new StringifiedObject() | ||
stringified.add('username', '[10, 20]') | ||
assert.equal(stringified.flush(), '{ username: { [10, 20] } }') | ||
}) | ||
}) |