|
| 1 | +const fs = require('fs-extra'); |
| 2 | +const globby = require('globby'); |
| 3 | +const path = require('path'); |
| 4 | +const { |
| 5 | + bootstrap, |
| 6 | + isSuccessfulDevelopment, |
| 7 | + isSuccessfulProduction, |
| 8 | +} = require('../../utils'); |
| 9 | +beforeEach(async () => { |
| 10 | + await bootstrap({ directory: global.testDirectory, template: __dirname }); |
| 11 | +}); |
| 12 | + |
| 13 | +describe('relative paths', () => { |
| 14 | + // TODO: enable when development relative paths are supported |
| 15 | + xit('builds in development', async () => { |
| 16 | + await isSuccessfulDevelopment({ directory: global.testDirectory }); |
| 17 | + }); |
| 18 | + it('builds in production', async () => { |
| 19 | + await isSuccessfulProduction({ directory: global.testDirectory }); |
| 20 | + |
| 21 | + const buildDir = path.join(global.testDirectory, 'build'); |
| 22 | + const cssFile = path.join( |
| 23 | + buildDir, |
| 24 | + globby.sync('**/*.css', { cwd: buildDir }).pop() |
| 25 | + ); |
| 26 | + const svgFile = path.join( |
| 27 | + buildDir, |
| 28 | + globby.sync('**/*.svg', { cwd: buildDir }).pop() |
| 29 | + ); |
| 30 | + const desiredPath = /url\((.+?)\)/ |
| 31 | + .exec(fs.readFileSync(cssFile, 'utf8')) |
| 32 | + .pop(); |
| 33 | + expect(path.resolve(path.join(path.dirname(cssFile), desiredPath))).toBe( |
| 34 | + path.resolve(svgFile) |
| 35 | + ); |
| 36 | + }); |
| 37 | +}); |
0 commit comments