UNPKG

1.7 kBtext/coffeescriptView Raw
1path = require 'path'
2q = require 'q'
3_ = require 'lodash'
4TWO_MINUTES = 120000
5
6gt.module 'using next-update as module',
7 setup: ->
8 process.chdir path.join(__dirname, 'test-next-updater')
9 teardown: ->
10 process.chdir __dirname
11
12nextUpdate = require '..'
13
14gt.test 'basics', ->
15 gt.func nextUpdate, 'next update is a function'
16
17gt.async 'check latest only updating', ->
18 opts =
19 module: 'check-types'
20 latest: true
21 promise = nextUpdate(opts)
22 gt.ok q.isPromise(promise), 'next update returns a promise'
23 promise.then -> console.log 'everything is ok'
24 promise.catch -> gt.ok false, 'promise failed'
25 promise.finally -> gt.start()
26, TWO_MINUTES
27
28# [ [ { name: 'check-types', version: '1.1.1', works: false } ] ]
29gt.async 'results format', ->
30 opts =
31 module: 'check-types'
32 latest: true
33 promise = nextUpdate(opts)
34 gt.ok q.isPromise(promise), 'next update returns a promise'
35 promise.then (result) ->
36 console.log 'Finished with', result
37 gt.array result, 'result should be an array'
38 result = _.flatten result
39 gt.length result, 1, 'single result'
40 gt.object result[0], 'single result is an object'
41 gt.equal result[0].name, 'check-types'
42 gt.string result[0].version, 'has version string'
43 gt.equal typeof result[0].works, 'boolean', 'has works property'
44 promise.catch -> gt.ok false, 'promise failed'
45 promise.finally -> gt.start()
46, TWO_MINUTES
47
48gt.async 'check all', ->
49 opts =
50 module: 'check-types'
51 promise = nextUpdate(opts)
52 promise.then -> gt.ok true, 'everything is ok'
53 promise.catch -> gt.ok false, 'promise failed'
54 promise.finally -> gt.start()
55, TWO_MINUTES