-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76e6d51
commit 6415acb
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import requirey from '../src/index'; | ||
|
||
const config = { | ||
lodash: ['1.3.1', '2.4.2', '3.10.1'] | ||
}; | ||
|
||
describe('requirey - integration', () => { | ||
let ry; | ||
beforeAll(() => { | ||
ry = requirey(config); | ||
}); | ||
|
||
it('should install all and be requireable', () => { | ||
ry.installAll(); | ||
let requirer = new ry.Requirer(); | ||
let a = requirer.require('lodash@1.3.1'); | ||
let b = requirer.require('lodash@2.4.2'); | ||
let c = requirer.require('lodash@3.10.1'); | ||
|
||
expect(a).toBeTruthy(); | ||
expect(b).toBeTruthy(); | ||
expect(c).toBeTruthy(); | ||
}); | ||
|
||
it('should fetch correct version', () => { | ||
let requirer = new ry.Requirer(); | ||
let a = requirer.require('lodash@1.3.1'); | ||
expect(a.drop).toBeTruthy(); //for 1.x | ||
expect(a.findLastIndex).toBeFalsy(); //for 2.x | ||
expect(a.chunk).toBeFalsy(); //for 3.x | ||
|
||
let b = requirer.require('lodash@2.4.2'); | ||
expect(b.drop).toBeTruthy(); //for 1.x | ||
expect(b.findLastIndex).toBeTruthy(); //for 2.x | ||
expect(b.chunk).toBeFalsy(); //for 3.x | ||
|
||
let c = requirer.require('lodash@3.10.1'); | ||
expect(c.drop).toBeTruthy(); //for 1.x | ||
expect(c.findLastIndex).toBeTruthy(); //for 2.x | ||
expect(c.chunk).toBeTruthy(); //for 3.x | ||
}); | ||
|
||
it('should find correct version intelligently', () => { | ||
let requirer_1 = new ry.Requirer({ | ||
dependencies: { | ||
lodash: '^3.0.0' | ||
} | ||
}); | ||
|
||
let a = requirer_1.require('lodash'); | ||
expect(a.chunk).toBeTruthy(); | ||
|
||
let requirer_2 = new ry.Requirer({ | ||
dependencies: { | ||
lodash: '^2.0.0' | ||
} | ||
}); | ||
|
||
let b = requirer_2.require('lodash'); | ||
expect(b.chunk).toBeFalsy(); | ||
expect(b.findLastIndex).toBeTruthy(); | ||
}); | ||
}); |