forked from yeoman/grunt-usemin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-config-requirejs.js
66 lines (57 loc) · 1.97 KB
/
test-config-requirejs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
var assert = require('assert');
var requirejsConfig = require('../lib/config/requirejs.js');
var helpers = require('./helpers');
var block = {
type: 'js',
dest: 'scripts/amd-app.js',
requirejs: {
dest: 'scripts/amd-app.js',
baseUrl: 'scripts',
name: 'main',
origScript: 'foo/require.js',
src: 'foo/require.js'
},
src: [
'foo/require.js'
],
raw: [
'<!-- build:js scripts/amd-app.js -->',
'<script data-main="scripts/main" src="foo/require.js"></script>',
'<!-- endbuild -->'
]
};
var blockWithoutRequirejs = {
type: 'js',
dest: 'scripts/amd-app.js',
src: [
'foo/require.js'
],
raw: [
'<!-- build:js scripts/amd-app.js -->',
'<script data-main="scripts/main" src="foo/require.js"></script>',
'<!-- endbuild -->'
]
};
describe('Requirejs config write', function() {
it('should use the input files correctly', function () {
var ctx = { inDir: 'zzz', inFiles: ['foo.js'], outDir: 'tmp/requirejs', outFiles: []};
var cfg = requirejsConfig.createConfig( ctx, block );
assert.deepEqual(cfg,helpers.normalize({
'default': {
'options': { 'name': 'main', 'out': 'tmp/requirejs/scripts/amd-app.js', 'baseUrl': 'zzz/scripts', 'mainConfigFile': 'zzz/scripts/main.js'}
}
}));
});
it('should do nothing if the block is not requirejs enabled', function() {
var ctx = { inDir: 'zzz', inFiles: ['foo.js'], outDir: 'tmp/requirejs', outFiles: []};
var cfg = requirejsConfig.createConfig( ctx, blockWithoutRequirejs);
assert.deepEqual(cfg, {});
});
it('should add a .js when needed to mainConfigFile', function() {
var ctx = { inDir: 'zzz', inFiles: ['foo.js'], outDir: 'tmp/requirejs', outFiles: []};
var cfg = requirejsConfig.createConfig( ctx, block );
assert.equal(cfg['default'].options.mainConfigFile, helpers.normalize('zzz/scripts/main.js'));
});
it('should treat multi-config requirejs');
});