-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs-dir-into-json.test.js
41 lines (39 loc) · 1.1 KB
/
js-dir-into-json.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import test from 'ava'
import path from 'path'
import { jsDirIntoJson, jsDirIntoJsonSync } from '../'
test(`Imports all js/json files into a single object preserving the file structure as the object structure`, async t => {
const res = await jsDirIntoJson(path.join(__dirname, './benchmark'))
const resSync = jsDirIntoJsonSync(path.join(__dirname, './benchmark'))
t.deepEqual(res, {
'users': {
'maria': {
'name': 'Maria',
'email': 'maria@hotmail.com'
},
'martin': {
'firstName': 'Martin',
'lastName': 'Gonzalez',
'fullName': 'Martin Gonzalez',
'email': 'tin@devtin.io'
},
'olivia': 'thats me!',
'some-guy': 'Un-altered'
},
products: [
'Product 1',
'Product 2'
],
someConfig: {
plugins: [
'plugin-1',
'plugin-2'
]
}
})
t.deepEqual(res, resSync)
})
test('Preserves getters / setters', async t => {
const res = await jsDirIntoJson(path.join(__dirname, './benchmark'))
res.users.martin.firstName = 'Fulano'
t.is(res.users.martin.fullName, 'Fulano Gonzalez')
})