1 | var cwd = process.cwd();
|
2 | var path = require('path');
|
3 | var initJspm = require('../src/init');
|
4 |
|
5 |
|
6 | describe('jspm plugin init', function(){
|
7 | var files, jspm, client;
|
8 | var basePath = ".";
|
9 |
|
10 | beforeEach(function(){
|
11 | files = [];
|
12 | jspm = {
|
13 | config: 'custom_config.js',
|
14 | loadFiles: ['src/**/*.js'],
|
15 | packages: 'custom_packages/',
|
16 | serveFiles: ['testfile.js']
|
17 | };
|
18 | client = {};
|
19 |
|
20 | initJspm(files, basePath, jspm, client);
|
21 | });
|
22 |
|
23 | it('should add adapter.js to the top of the files array', function(){
|
24 | expect(files[3].pattern).toEqual(cwd + '/src/adapter.js');
|
25 | expect(files[3].included).toEqual(true);
|
26 | });
|
27 |
|
28 | it('should add config.js to the top of the files array', function(){
|
29 | expect(files[2].pattern).toEqual(cwd + '/custom_config.js');
|
30 | expect(files[2].included).toEqual(true);
|
31 | });
|
32 |
|
33 | it('should add systemjs to the top of the files array', function(){
|
34 | expect(files[1].pattern).toEqual(cwd + '/custom_packages/system@*.js');
|
35 | expect(files[1].included).toEqual(true);
|
36 | });
|
37 |
|
38 | it('should add es6-module-loader to the top of the files array', function(){
|
39 | expect(files[0].pattern).toEqual(cwd + '/custom_packages/es6-module-loader@*.js');
|
40 | expect(files[0].included).toEqual(true);
|
41 | });
|
42 |
|
43 | it('should add files from jspm.loadFiles to client.expandedFiles', function(){
|
44 | expect(client.jspm.expandedFiles).toEqual(['src/adapter.js', 'src/init.js']);
|
45 | });
|
46 |
|
47 | it('should add files from jspm.serveFiles to the end of the files array as served files', function(){
|
48 | expect(files[files.length - 1].pattern).toEqual(cwd + '/testfile.js');
|
49 | expect(files[files.length - 1].included).toEqual(false);
|
50 | expect(files[files.length - 1].served).toEqual(true);
|
51 | expect(files[files.length - 1].watched).toEqual(true);
|
52 | });
|
53 |
|
54 | it('should use the configured jspm_packages path and include it in the files array', function(){
|
55 | expect(files[4].pattern).toEqual(path.resolve(cwd, './custom_packages/**/*'));
|
56 | expect(files[4].included).toEqual(false);
|
57 | expect(files[4].served).toEqual(true);
|
58 | expect(files[4].watched).toEqual(true);
|
59 | });
|
60 |
|
61 | });
|