Skip to content

Commit

Permalink
refactor: complete stringfiedObject api
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 9, 2020
1 parent afa64d9 commit 689f7fa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/StringifiedObject/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @module edge
*/

/*
* edge
*
Expand Down
44 changes: 44 additions & 0 deletions test/stringified-object.spec.ts
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] } }')
})
})

0 comments on commit 689f7fa

Please sign in to comment.