• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nicholaswmin / automap / 10322364029

09 Aug 2024 04:16PM UTC coverage: 94.947%. Remained the same
10322364029

Pull #30

github

web-flow
Merge bc369f8fe into a2bd0b724
Pull Request #30: [dyno] refactor: rewrite using immutable functions

510 of 521 branches covered (97.89%)

Branch coverage included in aggregate %.

2177 of 2309 relevant lines covered (94.28%)

27.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.5
/test/unit/lists/lazy-list/export.test.js
1
import test from 'node:test'
1✔
2

1✔
3
import { LazyList } from '../../../../src/list.js'
1✔
4
import { Mail } from '../../../util/model/index.js'
1✔
5

1✔
6
test('LazyList', async t => {
1✔
7
  let list
1✔
8

1✔
9
  await t.test('#exportForSave', async t => {
1✔
10
    let result = null
1✔
11

1✔
12
    await t.test('list has no items', async t => {
1✔
13
      t.beforeEach(() => {
1✔
14
        list = new LazyList({ from: [], type: Mail })
×
15

×
16
        result = list.exportForSave('sample:path')
×
17
      })
1✔
18
    })
1✔
19

1✔
20
    await t.test('list has items', async t => {
1✔
21
      t.beforeEach(() => {
1✔
22
        list = new LazyList({
13✔
23
          from: [{ id: 'u_1', name: 'John' }, { id: 'u_2', name: 'Mary' }]
13✔
24
        })
13✔
25

13✔
26
        result = list.exportForSave('sample:path')
13✔
27
      })
1✔
28

1✔
29
      await t.test('returns an object', t => {
1✔
30
        t.assert.ok(result)
1✔
31
        t.assert.strictEqual(typeof result, 'object')
1✔
32
      })
1✔
33

1✔
34
      await t.test('with a type property', async t => {
1✔
35
        t.assert.ok(Object.hasOwn(result, 'type'))
1✔
36

1✔
37
        await t.test('set to "hash"', t => {
1✔
38
          t.assert.strictEqual(result.type, 'hash')
1✔
39
        })
1✔
40
      })
1✔
41

1✔
42
      await t.test('with a value property', async t => {
1✔
43
        t.assert.ok(Object.hasOwn(result, 'value'))
1✔
44

1✔
45
        await t.test('set to an object', t => {
1✔
46
          t.assert.strictEqual(typeof result.value, 'object')
1✔
47
        })
1✔
48

1✔
49
        await t.test('with 2 keys', t => {
1✔
50
          t.assert.strictEqual(Object.keys(result.value).length, 2)
1✔
51
        })
1✔
52

1✔
53
        await t.test('matching the ids of the initial elements', t => {
1✔
54
          t.assert.strictEqual(Object.hasOwn(result.value, 'u_1'), true)
1✔
55
          t.assert.strictEqual(Object.hasOwn(result.value, 'u_2'), true)
1✔
56
        })
1✔
57

1✔
58
        await t.test('with values as JSON strings', t => {
1✔
59
          t.assert.strictEqual(Object.hasOwn(result.value, 'u_1'), true)
1✔
60
          t.assert.strictEqual(Object.hasOwn(result.value, 'u_2'), true)
1✔
61
        })
1✔
62

1✔
63
        await t.test('parsing the value JSONs', async t => {
1✔
64
          let parsed = []
1✔
65

1✔
66
          t.before(() => {
1✔
67
            parsed.push(
1✔
68
              JSON.parse(result.value.u_1),
1✔
69
              JSON.parse(result.value.u_2)
1✔
70
            )
1✔
71
          })
1✔
72

1✔
73
          await t.test('parsed results have an index', t => {
1✔
74
            parsed.forEach(parsed => {
1✔
75
              t.assert.ok(Object.hasOwn(parsed, 'i'))
2✔
76
            })
1✔
77
          })
1✔
78

1✔
79
          await t.test('index maps to the initial elements indices', t => {
1✔
80
            t.assert.strictEqual(parsed[0].i, 0)
1✔
81
            t.assert.strictEqual(parsed[1].i, 1)
1✔
82
          })
1✔
83

1✔
84
          await t.test('parsed results have a json property', t => {
1✔
85
            parsed.forEach(parsed => {
1✔
86
              t.assert.ok(Object.hasOwn(parsed, 'json'))
2✔
87
            })
1✔
88
          })
1✔
89

1✔
90
          await t.test('result.json maps to the initial elements', t => {
1✔
91
            t.assert.deepStrictEqual(parsed[0].json, list[0])
1✔
92
            t.assert.deepStrictEqual(parsed[1].json, list[1])
1✔
93
          })
1✔
94
        })
1✔
95
      })
1✔
96
    })
1✔
97
  })
1✔
98
})
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc