|
| 1 | +import execa from 'execa' |
| 2 | +import tempy from 'tempy' |
| 3 | + |
| 4 | +const path = require('path') |
| 5 | +const filesystem = require('fs-jetpack') |
| 6 | +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` |
| 7 | +const origCwd = process.cwd() |
| 8 | +let originalTimeout |
| 9 | + |
| 10 | +beforeAll(() => { |
| 11 | + // These can be slow on CI |
| 12 | + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL |
| 13 | + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 |
| 14 | +}) |
| 15 | + |
| 16 | +afterAll(function() { |
| 17 | + // Fix timeout change |
| 18 | + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout |
| 19 | +}) |
| 20 | + |
| 21 | +test('default looks for .solidarity file', async done => { |
| 22 | + const tempDir = tempy.directory() |
| 23 | + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) |
| 24 | + process.chdir(tempDir) |
| 25 | + try { |
| 26 | + await execa.shell(SOLIDARITY).then(result => { |
| 27 | + expect(result.stdout).toMatchSnapshot() |
| 28 | + done() |
| 29 | + }) |
| 30 | + } catch (err) { |
| 31 | + done.fail() |
| 32 | + } |
| 33 | +}) |
| 34 | + |
| 35 | +test('also looks for .solidarity.json file', async done => { |
| 36 | + const tempDir = tempy.directory() |
| 37 | + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity.json`) |
| 38 | + process.chdir(tempDir) |
| 39 | + try { |
| 40 | + await execa.shell(SOLIDARITY).then(result => { |
| 41 | + expect(result.stdout).toMatchSnapshot() |
| 42 | + done() |
| 43 | + }) |
| 44 | + } catch (err) { |
| 45 | + done.fail() |
| 46 | + } |
| 47 | +}) |
| 48 | + |
| 49 | +test('verbose flag works', async done => { |
| 50 | + const tempDir = tempy.directory() |
| 51 | + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) |
| 52 | + process.chdir(tempDir) |
| 53 | + try { |
| 54 | + await execa.shell(`${SOLIDARITY} --verbose`).then(result => { |
| 55 | + expect(result.stdout).toMatchSnapshot() |
| 56 | + done() |
| 57 | + }) |
| 58 | + } catch (err) { |
| 59 | + done.fail() |
| 60 | + } |
| 61 | +}) |
| 62 | + |
| 63 | +test('silent flag works', async done => { |
| 64 | + const tempDir = tempy.directory() |
| 65 | + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) |
| 66 | + process.chdir(tempDir) |
| 67 | + try { |
| 68 | + await execa.shell(`${SOLIDARITY} --silent`).then(result => { |
| 69 | + expect(result.stdout).toMatchSnapshot() |
| 70 | + done() |
| 71 | + }) |
| 72 | + } catch (err) { |
| 73 | + done.fail() |
| 74 | + } |
| 75 | +}) |
| 76 | + |
| 77 | +afterEach(() => { |
| 78 | + process.chdir(origCwd) |
| 79 | +}) |
0 commit comments