-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
cache_spec.js
60 lines (55 loc) · 1.46 KB
/
cache_spec.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require('../../spec_helper')
const mockfs = require('mock-fs')
const fs = require(`${lib}/fs`)
const state = require(`${lib}/tasks/state`)
const cache = require(`${lib}/tasks/cache`)
const stdout = require('../../support/stdout')
const snapshot = require('../../support/snapshot')
describe('lib/tasks/cache', () => {
beforeEach(() => {
mockfs({
'/.cache/Cypress': {
'1.2.3': {
'Cypress': {},
},
'2.3.4': {
'Cypress.app': {},
},
},
})
sinon.stub(state, 'getCacheDir').returns('/.cache/Cypress')
this.stdout = stdout.capture()
})
afterEach(() => {
mockfs.restore()
this.stdout = this.stdout.toString().split('\n').slice(0, -2).join('\n')
snapshot(this.stdout.toString() || '[no output]')
stdout.restore()
})
describe('.path', () => {
it('lists path to cache', () => {
cache.path()
expect(this.stdout.toString()).to.eql('/.cache/Cypress\n')
})
})
describe('.clear', () => {
it('deletes cache folder and everything inside it', () => {
return cache.clear()
.then(() => {
return fs.pathExistsAsync('/.cache/Cypress')
.then((exists) => {
return expect(exists).to.eql(false)
})
}
)
})
})
describe('.list', () => {
it('lists all versions of cached binary', () => {
return cache.list()
.then(() => {
expect(this.stdout.toString()).to.eql('1.2.3, 2.3.4\n')
})
})
})
})