-
Notifications
You must be signed in to change notification settings - Fork 282
/
index.test.js
259 lines (134 loc) · 5.15 KB
/
index.test.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
'use strict';
var path = require('path'),
should = require('should'),
ss = require( '../../../lib/socketstream'),
options = ss.client.options;
describe('client asset manager index', function () {
var origDefaultEntryInit = options.defaultEntryInit;
afterEach(function() {
ss.client.forget();
});
describe('#formatters', function () {
it('should return the code formatters API');
});
describe('#templateEngine', function () {
it('should return the templateEngine API');
});
describe('#systemAssets', function () {
it('should return the system assets API');
});
describe('#options', function () {
it('should return an object specifying the app\'s options');
});
describe('#set', function () {
it('should allow the user to overwrite the existing options');
});
describe('#packAssets', function () {
options.packedAssets = true;
it('should tell the asset manager to pack and minimise all assets', function() {
//TODO set project root function
ss.root = ss.api.root = path.join(__dirname, '../../fixtures/project');
var client = ss.client.define('abc', {
code: './abc/index.js',
view: './abc.html'
});
//ss.client.load();
});
});
describe('#define', function () {
options.packedAssets = false;
it('should return a client object containing a name, and the paths of all the files it has');
it('should throw an error if the name has already been used');
it('should throw an error if more than one HTML view is defined');
it('should throw an error if the html view is not a valid html template');
});
describe('#load', function () {
options.packedAssets = false;
it('should listen for incoming asset requests');
it('should load existing pre-packed assets, if they exist');
it('should re-pack assets in case they do not exist');
it('should otherwise serve files directly, and watch for changes to those files');
it('should also listen out for request to asynchronously load new assets');
});
var view = require('../../../lib/client/view');
describe('unpacked #view',function() {
beforeEach(function() {
// back to initial client state
ss.client.unload();
ss.client.assets.unload();
ss.client.forget();
ss.client.assets.load();
// options and load client
options.packedAssets = false;
ss.client.load();
});
afterEach(function() {
ss.client.unload();
});
it('should render the SS view');
});
describe('packed #view', function() {
beforeEach(function() {
// back to initial client state
ss.client.unload();
ss.client.assets.unload();
ss.client.forget();
ss.client.assets.load();
// options and load client
options.packedAssets = true;
ss.client.load();
});
afterEach(function() {
ss.client.unload();
});
it('should render the ABC view', function(done) {
var expectedHtml = '<html>\n' +
'<head><title>ABC</title></head>\n' +
'<body><p>ABC</p></body>\n' +
'</html>';
var client = ss.client.define('abc', {
css: './abc/style.css',
code: './abc/index.js',
view: './abc/abc.html'
});
view(ss.api, client, options, function(output) {
output.should.equal(expectedHtml);
done();
});
});
it('should render the SS view', function(done) {
var client = ss.client.define('abc', {
css: './abc/style.css',
code: './abc/index.js',
view: './abc/ss.html'
});
var expectedHtml = ('<html>\n' +
'<head><title>ABC</title>' +
'<link href="/assets/abc/m1bf9lApd.css" media="screen" rel="stylesheet" type="text/css">' +
'<script src="/assets/abc/m1bf9lApd.js" type="text/javascript"></script>'+ '</head>\n' +
'<body><p>ABC</p></body>\n' +
'</html>\n').replace(/m1bf9lApd/g,client.id);
view(ss.api, client, options, function(output) {
output.should.equal(expectedHtml);
done();
});
});
it('should render the SS view without CSS if include is false', function(done) {
var client = ss.client.define('abc', {
includes: {css:false},
css: './abc/style.css',
code: './abc/index.js',
view: './abc/ss.html'
});
var expectedHtml = ('<html>\n' +
'<head><title>ABC</title>' +
'<script src="/assets/abc/m1bf9lApd.js" type="text/javascript"></script>'+ '</head>\n' +
'<body><p>ABC</p></body>\n' +
'</html>\n').replace(/m1bf9lApd/g,client.id);
view(ss.api, client, options, function(output) {
output.should.equal(expectedHtml);
done();
});
});
});
});