-
Notifications
You must be signed in to change notification settings - Fork 10
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
Ralph Huwiler
committed
Feb 8, 2018
1 parent
cce94dd
commit d781a16
Showing
1 changed file
with
35 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,35 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-bumblebee | ||
* | ||
* (c) Ralph Huwiler <ralph@huwiler.rocks> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const test = require('japa') | ||
const { ioc } = require('@adonisjs/fold') | ||
|
||
const setup = require('./setup') | ||
|
||
test.group('Promise Data', (group) => { | ||
group.before(async () => { | ||
await setup() | ||
}) | ||
|
||
test('data can be a promis and will resolve before transforming', async (assert) => { | ||
const Context = ioc.use('Adonis/Src/HttpContext') | ||
const {transform} = new Context() | ||
|
||
let data = new Promise((resolve, reject) => { | ||
setTimeout(resolve, 1, {item_id: 3}) | ||
}) | ||
|
||
let transformed = await transform | ||
.item(data, model => ({id: model.item_id})) | ||
|
||
assert.equal(transformed.id, 3) | ||
}) | ||
}) |