Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite tests to use webpack compiler, drop node 8 #360

Merged
merged 25 commits into from
Mar 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix errors
  • Loading branch information
beeequeue committed Mar 4, 2021
commit 1d11c9e6413cbdbc72868536a5b33238ed3cc799
57 changes: 27 additions & 30 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,43 +131,40 @@ describe.each(versions)('%s', (_, DotenvPlugin) => {
})

test('Should expand variables when configured', (done) => {
const config = getConfig(
'web',
new DotenvPlugin({ path: envExpanded, expand: true })
)

compile(config, (result) => {
expectResultsToContainReplacements(result, {
NODE_ENV: 'test',
BASIC: 'basic',
BASIC_EXPAND: 'basic',
MACHINE: 'machine_env',
MACHINE_EXPAND: 'machine_env',
UNDEFINED_EXPAND: '',
// eslint-disable-next-line
ESCAPED_EXPAND: '\$ESCAPED',
MONGOLAB_DATABASE: 'heroku_db',
MONGOLAB_USER: 'username',
MONGOLAB_PASSWORD: 'password',
MONGOLAB_DOMAIN: 'abcd1234.mongolab.com',
MONGOLAB_PORT: '12345',
MONGOLAB_URI: 'mongodb:https://username:[email protected]:12345/heroku_db',
MONGOLAB_USER_RECURSIVELY: 'username:password',
MONGOLAB_URI_RECURSIVELY: 'mongodb:https://username:[email protected]:12345/heroku_db',
WITHOUT_CURLY_BRACES_URI: 'mongodb:https://username:[email protected]:12345/heroku_db',
WITHOUT_CURLY_BRACES_USER_RECURSIVELY: 'username:password',
WITHOUT_CURLY_BRACES_URI_RECURSIVELY: 'mongodb:https://username:[email protected]:12345/heroku_db'
})
const expected = {
NODE_ENV: 'test',
BASIC: 'basic',
BASIC_EXPAND: 'basic',
MACHINE: 'machine_env',
MACHINE_EXPAND: 'machine_env',
UNDEFINED_EXPAND: '',
// eslint-disable-next-line
ESCAPED_EXPAND: '\$ESCAPED',
MONGOLAB_DATABASE: 'heroku_db',
MONGOLAB_USER: 'username',
MONGOLAB_PASSWORD: 'password',
MONGOLAB_DOMAIN: 'abcd1234.mongolab.com',
MONGOLAB_PORT: '12345',
MONGOLAB_URI: 'mongodb:https://username:[email protected]:12345/heroku_db',
MONGOLAB_USER_RECURSIVELY: 'username:password',
MONGOLAB_URI_RECURSIVELY: 'mongodb:https://username:[email protected]:12345/heroku_db',
WITHOUT_CURLY_BRACES_URI: 'mongodb:https://username:[email protected]:12345/heroku_db',
WITHOUT_CURLY_BRACES_USER_RECURSIVELY: 'username:password',
WITHOUT_CURLY_BRACES_URI_RECURSIVELY: 'mongodb:https://username:[email protected]:12345/heroku_db'
}

done()
})
expectResultsToContainReplacements(
new DotenvPlugin({ path: envExpanded, expand: true }),
expected,
done
)
})
})

describe('Simple configuration', () => {
test('Should load enviornment variables when they exist in the .env file.', (done) => {
expectResultsToContainReplacements(
new DotenvPlugin({ path: envExpanded }),
new DotenvPlugin({ path: envSimple }),
simpleResult,
done
)
Expand Down