Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Commit 3aaab1d

Browse files
author
Michael Perrotte
committedFeb 28, 2020
fix: fixed function return type; added tests to catch a change like this
1 parent 58081b5 commit 3aaab1d

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ cmd.ls.stream = (org, opts = {}) => {
6363
mapJSON: (value, [key]) => {
6464
return [key, value]
6565
}
66-
}).collect()
66+
})
6767
}

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"check-coverage": true
2424
},
2525
"devDependencies": {
26+
"minipass": "^3.1.1",
2627
"nock": "^12.0.1",
2728
"standard": "^14.3.1",
2829
"standard-version": "^7.1.0",

‎test/index.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const Minipass = require('minipass')
34
const test = require('tap').test
45
const tnock = require('./fixtures/tnock.js')
56

@@ -94,27 +95,35 @@ test('ls', t => {
9495
})
9596

9697
test('ls stream with no options', t => {
98+
t.plan(2)
9799
const roster = {
98100
zkat: 'developer',
99101
iarna: 'admin',
100102
isaacs: 'owner'
101103
}
102104
const rosterArr = Object.keys(roster).map(k => [k, roster[k]])
103105
tnock(t, REG).get('/-/org/myorg/user').reply(200, roster)
104-
return org.ls.stream('myorg').then(res => {
105-
t.deepEqual(res, rosterArr, 'got back a roster, in entries format')
106-
})
106+
const result = org.ls.stream('myorg')
107+
t.ok(Minipass.isStream(result), 'returns a stream')
108+
return result.collect()
109+
.then(res => {
110+
t.deepEqual(res, rosterArr, 'got back a roster, in entries format')
111+
})
107112
})
108113

109114
test('ls stream', t => {
115+
t.plan(2)
110116
const roster = {
111117
zkat: 'developer',
112118
iarna: 'admin',
113119
isaacs: 'owner'
114120
}
115121
const rosterArr = Object.keys(roster).map(k => [k, roster[k]])
116122
tnock(t, OPTS.registry).get('/-/org/myorg/user').reply(200, roster)
117-
return org.ls.stream('myorg', OPTS).then(res => {
118-
t.deepEqual(res, rosterArr, 'got back a roster, in entries format')
119-
})
123+
const result = org.ls.stream('myorg', OPTS)
124+
t.ok(Minipass.isStream(result), 'returns a stream')
125+
return result.collect()
126+
.then(res => {
127+
t.deepEqual(res, rosterArr, 'got back a roster, in entries format')
128+
})
120129
})

0 commit comments

Comments
 (0)
This repository has been archived.