Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
debopamsengupta committed Apr 24, 2017
1 parent 76e6d51 commit 6415acb
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions integration/integration.test.js
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();
});
});

0 comments on commit 6415acb

Please sign in to comment.