|
| 1 | +import { expect } from 'chai'; |
| 2 | +import sinon from 'sinon'; |
| 3 | +import { Config } from '../config'; |
| 4 | +import { macOSSignAndNotarize } from './macos-sign'; |
| 5 | + |
| 6 | +describe('packaging macos-sign', () => { |
| 7 | + describe('macOSSignAndNotarize', () => { |
| 8 | + let config: Config; |
| 9 | + let signStub: sinon.SinonStub; |
| 10 | + let notarizeStub: sinon.SinonStub; |
| 11 | + let runCreatePackageStub: sinon.SinonStub; |
| 12 | + |
| 13 | + before(() => { |
| 14 | + config = { |
| 15 | + appleCodesignIdentity: 'signingIdentity', |
| 16 | + appleCodesignEntitlementsFile: 'entitlementsFile', |
| 17 | + appleNotarizationBundleId: 'bundleId', |
| 18 | + appleNotarizationUsername: 'username', |
| 19 | + appleNotarizationApplicationPassword: 'password' |
| 20 | + } as Config; |
| 21 | + |
| 22 | + signStub = sinon.stub().resolves(); |
| 23 | + notarizeStub = sinon.stub().resolves(); |
| 24 | + runCreatePackageStub = sinon.stub().resolves({ |
| 25 | + path: 'package/path', |
| 26 | + contentType: 'pkg' |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + context('processes the package', () => { |
| 31 | + before(async() => { |
| 32 | + await macOSSignAndNotarize( |
| 33 | + [ |
| 34 | + 'executable1', 'executable2' |
| 35 | + ], |
| 36 | + config, |
| 37 | + runCreatePackageStub, |
| 38 | + signStub, |
| 39 | + notarizeStub |
| 40 | + ); |
| 41 | + }); |
| 42 | + |
| 43 | + it('signs all executables', () => { |
| 44 | + expect(signStub).to.have.been.calledTwice; |
| 45 | + expect(signStub).to.have.been.calledWith('executable1', config.appleCodesignIdentity, config.appleCodesignEntitlementsFile); |
| 46 | + expect(signStub).to.have.been.calledWith('executable2', config.appleCodesignIdentity, config.appleCodesignEntitlementsFile); |
| 47 | + }); |
| 48 | + |
| 49 | + it('creates the package', () => { |
| 50 | + expect(runCreatePackageStub).to.have.been.called; |
| 51 | + }); |
| 52 | + |
| 53 | + it('notarizes the package', () => { |
| 54 | + expect(notarizeStub).to.have.been.calledWith( |
| 55 | + config.appleNotarizationBundleId, |
| 56 | + 'package/path', |
| 57 | + config.appleNotarizationUsername, |
| 58 | + config.appleNotarizationApplicationPassword |
| 59 | + ); |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | +}); |
0 commit comments