Navigation Menu

Skip to content

Commit

Permalink
fix: Fix environment variables issues during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
windkomo committed Feb 16, 2018
1 parent 871cf6a commit 626bcfb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/botfuel-dialog/package.json
Expand Up @@ -77,7 +77,8 @@
"prettier-eslint": "^8.3.1",
"prettier-eslint-cli": "^4.6.1",
"regenerator-runtime": "^0.11.1",
"replay": "^2.1.4"
"replay": "^2.1.4",
"sinon": "^4.3.0"
},
"engines": {
"node": "8.x"
Expand Down
19 changes: 13 additions & 6 deletions packages/botfuel-dialog/tests/utils/environment.test.js
Expand Up @@ -14,16 +14,23 @@
* limitations under the License.
*/

const sinon = require('sinon');
const { checkCredentials } = require('../../src/utils/environment');
const { defaultConfig } = require('../../src/config');
const MissingCredentialsError = require('../../src/errors/missing-credentials-error');

const buildConfig = configPart => Object.assign({}, defaultConfig, configPart);

describe('Environment utils', () => {
const sandbox = sinon.sandbox.create();

afterAll(() => {
sandbox.restore();
});

describe('When BOTFUEL_APP_TOKEN is not defined', () => {
beforeAll(() => {
delete process.env.BOTFUEL_APP_TOKEN;
beforeEach(() => {
sandbox.stub(process, 'env').value({ BOTFUEL_APP_TOKEN: undefined });
});

test('should throw an error when using botfuel adapter', async () => {
Expand All @@ -40,8 +47,8 @@ describe('Environment utils', () => {
});

describe('When BOTFUEL_APP_ID is not defined', () => {
beforeAll(() => {
delete process.env.BOTFUEL_APP_ID;
beforeEach(() => {
sandbox.stub(process, 'env').value({ BOTFUEL_APP_ID: undefined });
});

test('should throw an error when using botfuel QnA', async () => {
Expand All @@ -58,8 +65,8 @@ describe('Environment utils', () => {
});

describe('When BOTFUEL_APP_KEY is not defined', () => {
beforeAll(() => {
delete process.env.BOTFUEL_APP_KEY;
beforeEach(() => {
sandbox.stub(process, 'env').value({ BOTFUEL_APP_KEY: undefined });
});

test('should throw an error when using botfuel QnA', async () => {
Expand Down
20 changes: 19 additions & 1 deletion yarn.lock
Expand Up @@ -2,6 +2,12 @@
# yarn lockfile v1


"@sinonjs/formatio@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2"
dependencies:
samsam "1.3.0"

JSONStream@^1.0.4:
version "1.3.2"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea"
Expand Down Expand Up @@ -4977,7 +4983,7 @@ safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, s
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"

samsam@1.x:
samsam@1.3.0, samsam@1.x:
version "1.3.0"
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50"

Expand Down Expand Up @@ -5096,6 +5102,18 @@ sinon@^4.1.5:
supports-color "^5.1.0"
type-detect "^4.0.5"

sinon@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.3.0.tgz#cec9b27d5f4e2c63c1a79c9dc1c05d34bb088234"
dependencies:
"@sinonjs/formatio" "^2.0.0"
diff "^3.1.0"
lodash.get "^4.4.2"
lolex "^2.2.0"
nise "^1.2.0"
supports-color "^5.1.0"
type-detect "^4.0.5"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
Expand Down

0 comments on commit 626bcfb

Please sign in to comment.