-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from zonkyio/tests-cleanup
Tests cleanup
- Loading branch information
Showing
7 changed files
with
406 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,104 @@ | ||
'use strict'; | ||
const assert = require('assert'); | ||
const { AddonTestApp } = require('ember-cli-addon-tests'); | ||
const { contentOf, exists, assertJSON } = require('./helpers'); | ||
|
||
let assert = require('assert'); | ||
let fs = require('fs'); | ||
let AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; | ||
describe('Acceptance', function() { | ||
describe('browserconfig', function() { | ||
this.timeout(300000); | ||
|
||
describe('Acceptance: browserconfig file generation', function() { | ||
this.timeout(300000); | ||
let app; | ||
|
||
let app; | ||
before(function() { | ||
if (process.env.SKIP_ACCEPTANCE === 'true') { | ||
this.skip(); | ||
return; | ||
} | ||
|
||
before(function() { | ||
if (process.env.SKIP_ACCEPTANCE === 'true') { | ||
this.skip(); | ||
return; | ||
} | ||
app = new AddonTestApp(); | ||
}); | ||
|
||
app = new AddonTestApp(); | ||
}); | ||
|
||
it('generates a browserconfig.xml file', function() { | ||
return app | ||
.create('empty', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(function() { | ||
return app.runEmberCommand('build'); | ||
}) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(function(content) { | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication/></browserconfig>' | ||
it('generates a browserconfig.xml file', function() { | ||
return app | ||
.create('empty', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(() => app.runEmberCommand('build')) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(content => | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication/></browserconfig>' | ||
) | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it('configures broccoli-asset-rev', function() { | ||
return app | ||
.create('dummy', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(function() { | ||
return app.runEmberCommand('build', '--prod'); | ||
}) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(function(content) { | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>' | ||
); | ||
}) | ||
.then(contentOf(app, 'dist/fastbootAssetMap.json')) | ||
.then(assertJSON(app, { 'pio.png': 'pio-0987654321.png' })); | ||
}); | ||
it('configures broccoli-asset-rev', function() { | ||
return app | ||
.create('dummy', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(() => app.runEmberCommand('build', '--prod')) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(content => | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>' | ||
) | ||
) | ||
.then(contentOf(app, 'dist/fastbootAssetMap.json')) | ||
.then(assertJSON(app, { 'pio.png': 'pio-0987654321.png' })); | ||
}); | ||
|
||
it(`doesn't generate browserconfig when tag is omitted`, function() { | ||
return app | ||
.create('no-browserconfig', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(function() { | ||
return app.runEmberCommand('build'); | ||
}) | ||
.then(function() { | ||
assert.ok( | ||
!fs.existsSync(app.filePath('dist/browserconfig.xml')), | ||
`Doesn't generate browserconfig.xml file` | ||
it(`doesn't generate browserconfig when tag is omitted`, function() { | ||
return app | ||
.create('no-browserconfig', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(() => app.runEmberCommand('build')) | ||
.then(() => | ||
assert.ok( | ||
!exists(app, 'dist/browserconfig.xml'), | ||
`Doesn't generate browserconfig.xml file` | ||
) | ||
) | ||
.then(contentOf(app, 'dist/index.html')) | ||
.then(content => | ||
assert.ok( | ||
!content.includes('msapplication-config'), | ||
`Doesn't include meta tags` | ||
) | ||
); | ||
}) | ||
.then(contentOf(app, 'dist/index.html')) | ||
.then(function(content) { | ||
assert.ok( | ||
!content.includes('msapplication-config'), | ||
`Doesn't include meta tags` | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it('uses rootURL configuration', function() { | ||
return app | ||
.create('config-root-url', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(function() { | ||
return app.runEmberCommand('build'); | ||
}) | ||
.then(contentOf(app, 'dist/index.html')) | ||
.then(function(content) { | ||
assert.ok( | ||
content.indexOf('content="/foo/bar/baz/browserconfig.xml"') > -1, | ||
'index.html uses rootURL from configuration' | ||
it('uses rootURL configuration', function() { | ||
return app | ||
.create('config-root-url', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(() => app.runEmberCommand('build')) | ||
.then(contentOf(app, 'dist/index.html')) | ||
.then(content => | ||
assert.ok( | ||
content.indexOf('content="/foo/bar/baz/browserconfig.xml"') > -1, | ||
'index.html uses rootURL from configuration' | ||
) | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
it('uses fingerprint configuration for browserconfig', function() { | ||
return app | ||
.create('broccoli-asset-rev', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(function() { | ||
return app.runEmberCommand('build', '--prod'); | ||
}) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(function(content) { | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>' | ||
it('uses fingerprint configuration for browserconfig', function() { | ||
return app | ||
.create('broccoli-asset-rev', { | ||
fixturesPath: 'node-tests/acceptance/fixtures', | ||
}) | ||
.then(() => app.runEmberCommand('build', '--prod')) | ||
.then(contentOf(app, 'dist/browserconfig.xml')) | ||
.then(content => | ||
assert.strictEqual( | ||
content, | ||
'<?xml version="1.0"?><browserconfig><msapplication><tile><square150x150logo src="https://www.example.com/pio-8911090226e7b5522790f1218f6924a5.png"/><TileColor>#FFFFFF</TileColor></tile></msapplication></browserconfig>' | ||
) | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function contentOf(app, path) { | ||
return function() { | ||
return fs.readFileSync(app.filePath(path), { encoding: 'utf-8' }); | ||
}; | ||
} | ||
|
||
function assertJSON(app, expected) { | ||
return function(actual) { | ||
assert.deepStrictEqual(JSON.parse(actual), expected, 'assert JSON'); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
module.exports = { contentOf, exists, assertJSON }; | ||
|
||
function contentOf(app, path) { | ||
return () => fs.readFileSync(app.filePath(path), { encoding: 'utf-8' }); | ||
} | ||
|
||
function exists(app, path) { | ||
return fs.existsSync(app.filePath(path)); | ||
} | ||
|
||
function assertJSON(app, expected) { | ||
return actual => | ||
assert.deepStrictEqual(JSON.parse(actual), expected, 'assert JSON'); | ||
} |
Oops, something went wrong.