|
| 1 | +import { tmpdir } from "os"; |
| 2 | +import { assert } from "chai"; |
| 3 | +import * as rimraf from "rimraf"; |
| 4 | + |
| 5 | +import { FileSystem } from "../../lib/wrappers/file-system"; |
| 6 | + |
| 7 | +describe('FileSystem', () => { |
| 8 | + describe('extractZip', () => { |
| 9 | + const d = new Date(); |
| 10 | + const datetime = [ |
| 11 | + d.getFullYear(), |
| 12 | + d.getMonth() + 1, |
| 13 | + d.getDate(), |
| 14 | + d.getHours(), |
| 15 | + d.getMinutes(), |
| 16 | + d.getSeconds(), |
| 17 | + d.getMilliseconds() |
| 18 | + ].join(''); |
| 19 | + const tmpDir = `${tmpdir()}/${datetime}`; |
| 20 | + const testFilePath = `${__dirname}/example.zip`; |
| 21 | + const filesThatNeedToExtsit = [ |
| 22 | + `${tmpDir}/test/android-local-build-requirements.ts`, |
| 23 | + `${tmpDir}/test/android-tools-info.ts`, |
| 24 | + `${tmpDir}/test/ios-local-build-requirements.ts`, |
| 25 | + `${tmpDir}/test/sys-info.ts`, |
| 26 | + `${tmpDir}/test/wrappers/file-system.ts` |
| 27 | + ]; |
| 28 | + |
| 29 | + it('should extract in example zip archive in tmp folder', done => { |
| 30 | + const fs = new FileSystem(); |
| 31 | + |
| 32 | + fs.extractZip(testFilePath, tmpDir) |
| 33 | + .then(() => { |
| 34 | + const allExists = filesThatNeedToExtsit |
| 35 | + .map(fs.exists) |
| 36 | + .reduce((acc, r) => acc && r, true); |
| 37 | + |
| 38 | + assert.isTrue(allExists); |
| 39 | + |
| 40 | + done(); |
| 41 | + }) |
| 42 | + .catch(e => done(e)); |
| 43 | + }); |
| 44 | + |
| 45 | + afterEach(done => rimraf(tmpDir, done)); |
| 46 | + }); |
| 47 | +}); |
0 commit comments