Skip to content

Commit

Permalink
Update test assertions for unit tests to assert function ordering for…
Browse files Browse the repository at this point in the history
… download first then build
  • Loading branch information
jmartin4563 committed Aug 7, 2023
1 parent aa22111 commit b978dec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/unit/pre-build.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ tap.test('pre-build tests', (t) => {
t.equal(preBuild.saveDownload.callCount, 1, 'should save download')
})

t.test('should try download then build by default', async (t) => {
t.test('should attempt download first then build if download fails by default', async (t) => {
const data = 'foo'
preBuild.download.resolves(data)
preBuild.saveDownload.rejects(new Error('whoops'))
Expand All @@ -360,10 +360,11 @@ tap.test('pre-build tests', (t) => {

await preBuild.install('target')

t.equal(preBuild.build.callCount, 1, 'should build')
t.equal(preBuild.moveBuild.callCount, 1, 'should move build')
t.equal(preBuild.download.callCount, 1, 'should download')
t.equal(preBuild.saveDownload.callCount, 1, 'should save download')
t.ok(preBuild.download.calledBefore(preBuild.saveDownload), 'should download first')
t.ok(preBuild.saveDownload.calledAfter(preBuild.download), 'should save download second')

t.ok(preBuild.build.calledAfter(preBuild.saveDownload), 'should build third')
t.ok(preBuild.moveBuild.calledAfter(preBuild.build), 'should move build last')
})

t.test('should throw when download fails and noBuild is set', async (t) => {
Expand Down

0 comments on commit b978dec

Please sign in to comment.