|
3 | 3 | const app = require('../'); |
4 | 4 | const rcs = require('rcs-core'); |
5 | 5 | const fs = require('fs-extra'); |
| 6 | +const json = require('json-extra'); |
6 | 7 | const expect = require('chai').expect; |
7 | 8 |
|
8 | 9 | const testCwd = 'test/files/testCache'; |
@@ -194,101 +195,62 @@ describe('app.js', () => { |
194 | 195 | }); |
195 | 196 |
|
196 | 197 | it('should create the normal library file', done => { |
197 | | - app.generateLibraryFile(testCwd, (err, data) => { |
198 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map.js', 'utf8'); |
| 198 | + app.generateMapping(testCwd, (err, data) => { |
| 199 | + const cssMapping = json.readToObjSync(testCwd + '/renaming_map.json', 'utf8'); |
199 | 200 |
|
200 | 201 | expect(err).to.not.exist; |
201 | | - |
202 | | - // TODO read variable and check values |
203 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
| 202 | + expect(cssMapping['.jp-block']).to.equal('a'); |
| 203 | + expect(cssMapping['.jp-block__element']).to.equal('b'); |
204 | 204 |
|
205 | 205 | done(); |
206 | 206 |
|
207 | 207 | }); |
208 | 208 | }); |
209 | 209 |
|
210 | 210 | it('should create the minified library file', done => { |
211 | | - app.generateLibraryFile(testCwd, { |
| 211 | + app.generateMapping(testCwd, { |
212 | 212 | cssMapping: false, |
213 | 213 | cssMappingMin: true |
214 | 214 | }, (err, data) => { |
215 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map_min.js', 'utf8'); |
| 215 | + const cssMapping = json.readToObjSync(testCwd + '/renaming_map_min.json', 'utf8'); |
216 | 216 |
|
217 | 217 | expect(err).to.not.exist; |
218 | | - |
219 | | - // TODO read variable and check values |
220 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
| 218 | + expect(cssMapping['.a']).to.equal('jp-block'); |
| 219 | + expect(cssMapping['.b']).to.equal('jp-block__element'); |
221 | 220 |
|
222 | 221 | done(); |
223 | 222 |
|
224 | 223 | }); |
225 | 224 | }); |
226 | 225 |
|
227 | 226 | it('should create the extended normal library file', done => { |
228 | | - app.generateLibraryFile(testCwd, { |
| 227 | + app.generateMapping(testCwd, { |
229 | 228 | extended: true |
230 | 229 | }, (err, data) => { |
231 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map.js', 'utf8'); |
| 230 | + const cssMapping = json.readToObjSync(testCwd + '/renaming_map.json', 'utf8'); |
232 | 231 |
|
233 | 232 | expect(err).to.not.exist; |
234 | | - |
235 | | - // TODO read variable and check values |
236 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
| 233 | + expect(cssMapping['.jp-block']).to.be.an('object'); |
| 234 | + expect(cssMapping['.jp-block']).to.have.any.keys('type', 'typeChar'); |
| 235 | + expect(cssMapping['.jp-block']['type']).to.equal('class'); |
237 | 236 |
|
238 | 237 | done(); |
239 | 238 |
|
240 | 239 | }); |
241 | 240 | }); |
242 | 241 |
|
243 | 242 | it('should create the minified library file', done => { |
244 | | - app.generateLibraryFile(testCwd, { |
| 243 | + app.generateMapping(testCwd, { |
245 | 244 | cssMapping: false, |
246 | 245 | cssMappingMin: true, |
247 | 246 | extended: true |
248 | 247 | }, (err, data) => { |
249 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map_min.js', 'utf8'); |
250 | | - |
251 | | - expect(err).to.not.exist; |
252 | | - |
253 | | - // TODO read variable and check values |
254 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
255 | | - |
256 | | - done(); |
257 | | - |
258 | | - }); |
259 | | - }); |
260 | | - |
261 | | - it('should create the both library files', done => { |
262 | | - app.generateLibraryFile(testCwd, { |
263 | | - cssMapping: true, |
264 | | - cssMappingMin: true |
265 | | - }, (err, data) => { |
266 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map.js', 'utf8'); |
267 | | - const cssMappingMin = fs.readFileSync(testCwd + '/renaming_map_min.js', 'utf8'); |
| 248 | + const cssMappingMin = json.readToObjSync(testCwd + '/renaming_map_min.json', 'utf8'); |
268 | 249 |
|
269 | 250 | expect(err).to.not.exist; |
270 | | - |
271 | | - // TODO read variable and check values |
272 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
273 | | - |
274 | | - done(); |
275 | | - |
276 | | - }); |
277 | | - }); |
278 | | - |
279 | | - it('should create the both extended library files', done => { |
280 | | - app.generateLibraryFile(testCwd, { |
281 | | - extended: true, |
282 | | - cssMapping: true, |
283 | | - cssMappingMin: true |
284 | | - }, (err, data) => { |
285 | | - const cssMapping = fs.readFileSync(testCwd + '/renaming_map.js', 'utf8'); |
286 | | - const cssMappingMin = fs.readFileSync(testCwd + '/renaming_map_min.js', 'utf8'); |
287 | | - |
288 | | - expect(err).to.not.exist; |
289 | | - |
290 | | - // TODO read variable and check values |
291 | | - // expect(cssMapping['jp-block']).to.equal('a'); |
| 251 | + expect(cssMappingMin['.a']).to.be.an('object'); |
| 252 | + expect(cssMappingMin['.a']).to.have.any.keys('type', 'typeChar'); |
| 253 | + expect(cssMappingMin['.a']['type']).to.equal('class'); |
292 | 254 |
|
293 | 255 | done(); |
294 | 256 |
|
|
0 commit comments