Skip to content

Commit

Permalink
WIP add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanita Barrett committed Nov 15, 2021
1 parent 4fa0685 commit 751f06e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tasks/gulp/__tests__/after-build-package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ var glob = require('glob')

const configPaths = require('../../../config/paths.json')
const lib = require('../../../lib/file-helper')
const helperFunctions = require('../../../lib/helper-functions')

const { renderSass } = require('../../../lib/jest-helpers')

const readFile = util.promisify(fs.readFile)
const componentNames = lib.allComponents.slice()
const componentsWithJavaScript = glob.sync(configPaths.package + 'govuk/components/' + '**/!(*.test).js')

describe('package/', () => {
it('should contain the expected files', () => {
Expand Down Expand Up @@ -127,6 +129,20 @@ describe('package/', () => {
})
})

describe('components with JavaScript', () => {
it.each(componentsWithJavaScript)('\'%s\' should have component JavaScript file with correct module name', (javaScriptFile) => {
let moduleName = helperFunctions.componentNameToJavaScriptModuleName(path.parse(javaScriptFile).name)

return readFile(javaScriptFile, 'utf8')
.then((data) => {
expect(data).toContain("typeof define === 'function' && define.amd ? define('" + moduleName + "', factory)")
})
.catch(error => {
throw error
})
})
})

describe('fixtures', () => {
it.each(componentNames)('\'%s\' should have fixtures.json that contains JSON', (name) => {
const filePath = path.join(configPaths.package, 'govuk', 'components', name, 'fixtures.json')
Expand Down

0 comments on commit 751f06e

Please sign in to comment.