|
1 |
| -'use strict'; |
2 |
| -const expect = require('chai').expect; |
| 1 | +const {expect} = require('chai'); |
3 | 2 | const sinon = require('sinon');
|
4 | 3 | const createConfigStub = require('../utils/config-stub');
|
| 4 | +const {setupTestFolder} = require('../utils/test-folder'); |
5 | 5 |
|
6 | 6 | const Instance = require('../../lib/instance');
|
7 | 7 | const Config = require('../../lib/utils/config');
|
@@ -449,6 +449,52 @@ describe('Unit: Instance', function () {
|
449 | 449 | });
|
450 | 450 | });
|
451 | 451 |
|
| 452 | + it('getAvailableConfigs returns available configs', async function () { |
| 453 | + const {dir, cleanup} = setupTestFolder({ |
| 454 | + files: [{ |
| 455 | + path: 'config.development.json', |
| 456 | + content: { |
| 457 | + env: 'development' |
| 458 | + }, |
| 459 | + json: true |
| 460 | + }, { |
| 461 | + path: 'config.staging.json', |
| 462 | + content: { |
| 463 | + env: 'staging' |
| 464 | + }, |
| 465 | + json: true |
| 466 | + }, { |
| 467 | + path: 'config.production.json', |
| 468 | + content: { |
| 469 | + env: 'production' |
| 470 | + }, |
| 471 | + json: true |
| 472 | + }, { |
| 473 | + path: 'somefile.txt', |
| 474 | + content: 'filecontents' |
| 475 | + }] |
| 476 | + }); |
| 477 | + |
| 478 | + try { |
| 479 | + const instance = new Instance({}, {}, dir); |
| 480 | + const results = await instance.getAvailableConfigs(); |
| 481 | + |
| 482 | + expect(results.development).to.exist; |
| 483 | + expect(results.development).to.be.an.instanceof(Config); |
| 484 | + expect(results.development.get('env')).to.equal('development'); |
| 485 | + |
| 486 | + expect(results.staging).to.exist; |
| 487 | + expect(results.staging).to.be.an.instanceof(Config); |
| 488 | + expect(results.staging.get('env')).to.equal('staging'); |
| 489 | + |
| 490 | + expect(results.production).to.exist; |
| 491 | + expect(results.production).to.be.an.instanceof(Config); |
| 492 | + expect(results.production.get('env')).to.equal('production'); |
| 493 | + } finally { |
| 494 | + cleanup(); |
| 495 | + } |
| 496 | + }); |
| 497 | + |
452 | 498 | describe('start', function () {
|
453 | 499 | it('skips enable functionality if enable param is false', async function () {
|
454 | 500 | const process = {
|
|
0 commit comments