Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JavaScript global namespace from 'all' to 'GOVUKFrontend' #747

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Note: We're not following semantic versioning yet, we are going to talk about th
nunjucks paths.
([PR #743](https://github.com/alphagov/govuk-frontend/pull/743))

- Update JavaScript global namespace from 'all' to 'GOVUKFrontend',
we intend to allow users to initialize components from this namespace.
([PR #747](https://github.com/alphagov/govuk-frontend/pull/747))


🆕 New features:

- Add `beforeContent` block to the template, for content that does not belong inside `<main>` element.
Expand Down
28 changes: 28 additions & 0 deletions src/all.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/**
* @jest-environment ./lib/puppeteer/environment.js
*/
/* eslint-env jest */

const util = require('util')

const configPaths = require('../config/paths.json')
const PORT = configPaths.ports.test

const sass = require('node-sass')
const sassRender = util.promisify(sass.render)
Expand All @@ -11,7 +15,31 @@ const sassConfig = {
includePaths: [ configPaths.src ]
}

let browser
let page
let baseUrl = 'http://localhost:' + PORT

beforeAll(async (done) => {
browser = global.__BROWSER__
page = await browser.newPage()
done()
})

afterAll(async (done) => {
await page.close()
done()
})

describe('GOV.UK Frontend', () => {
describe('javascript', async() => {
it('can be accessed via `GOVUKFrontend`', async () => {
await page.goto(baseUrl + '/', { waitUntil: 'load' })

const GOVUKFrontendGlobal = await page.evaluate(() => window.GOVUKFrontend)

expect(typeof GOVUKFrontendGlobal).toBe('object')
})
})
describe('global styles', async() => {
it('are disabled by default', async () => {
const sass = `
Expand Down
2 changes: 2 additions & 0 deletions tasks/gulp/compile-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ gulp.task('js:compile', () => {
srcFiles
])
.pipe(rollup({
// Used to set the `window` global and UMD/AMD export name.
name: 'GOVUKFrontend',
// Legacy mode is required for IE8 support
legacy: true,
// UMD allows the published bundle to work in CommonJS and in the browser.
Expand Down