33
44const checkUsage = require ( './helpers/utils' ) . checkOutput
55const expect = require ( 'chai' ) . expect
6+ const english = require ( '../locales/en.json' )
67let yargs = require ( '../' )
78
89require ( 'chai' ) . should ( )
@@ -13,13 +14,15 @@ describe('validation tests', () => {
1314 } )
1415
1516 describe ( 'implies' , ( ) => {
17+ const implicationsFailedPattern = new RegExp ( english [ 'Implications failed:' ] )
18+
1619 it ( "fails if '_' populated, and implied argument not set" , ( done ) => {
1720 yargs ( [ 'cat' ] )
1821 . implies ( {
1922 1 : 'foo' // 1 arg in _ means --foo is required
2023 } )
2124 . fail ( ( msg ) => {
22- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
25+ msg . should . match ( implicationsFailedPattern )
2326 return done ( )
2427 } )
2528 . parse ( )
@@ -32,7 +35,7 @@ describe('validation tests', () => {
3235 'foo' : 1 // --foo means 1 arg in _ is required
3336 } )
3437 . fail ( ( msg ) => {
35- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
38+ msg . should . match ( implicationsFailedPattern )
3639 return done ( )
3740 } )
3841 . parse ( )
@@ -62,7 +65,7 @@ describe('validation tests', () => {
6265 '--no-bar' : 'foo' // when --bar is not given, --foo is required
6366 } )
6467 . fail ( ( msg ) => {
65- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
68+ msg . should . match ( implicationsFailedPattern )
6669 return done ( )
6770 } )
6871 . parse ( )
@@ -74,7 +77,7 @@ describe('validation tests', () => {
7477 'bar' : '--no-foo' // --bar means --foo cannot be given
7578 } )
7679 . fail ( ( msg ) => {
77- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
80+ msg . should . match ( implicationsFailedPattern )
7881 return done ( )
7982 } )
8083 . parse ( )
@@ -89,7 +92,7 @@ describe('validation tests', () => {
8992 } )
9093 . fail ( ( msg ) => {
9194 failCalled = true
92- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
95+ msg . should . match ( implicationsFailedPattern )
9396 } )
9497 . parse ( )
9598 failCalled . should . equal ( true )
@@ -121,7 +124,7 @@ describe('validation tests', () => {
121124 } )
122125 . fail ( ( msg ) => {
123126 failCalled = true
124- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
127+ msg . should . match ( implicationsFailedPattern )
125128 } )
126129 . parse ( )
127130 failCalled . should . equal ( true )
@@ -150,7 +153,7 @@ describe('validation tests', () => {
150153 implies : 'foo'
151154 } )
152155 . fail ( ( msg ) => {
153- msg . should . match ( / I m p l i c a t i o n s f a i l e d / )
156+ msg . should . match ( implicationsFailedPattern )
154157 return done ( )
155158 } )
156159 . parse ( )
0 commit comments