Skip to content

Commit f0699df

Browse files
committed
Fixed mocha tests.
1 parent 3a1557d commit f0699df

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/master-interfaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = (API, addToOutput) => {
3434
// We must be a structure or something
3535
return
3636
}
37-
if (!isClass || module.name != classify(module.name)) {
37+
if (!isClass || module.name !== classify(module.name)) {
3838
if (isClass) {
3939
constDeclarations.push(
4040
`type ${classify(module.name)} = ${_.upperFirst(module.name)};`,

test/output_spec.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ const path = require('path')
88
const OUTPUT_PATH = path.resolve(__dirname, '..', 'electron.d.ts')
99
let output
1010

11+
function getDefinitionsForInterface (interfaceName) {
12+
const interface_ = output.match(interfaceName + '[^{]+{([\\s\\S]+?)}')
13+
expect(interface_).to.be.an('array')
14+
return interface_[1].split(';').map(l => l.trim())
15+
}
16+
1117
describe('Definition File', function () {
1218
this.timeout(20000)
1319

1420
before((done) => {
1521
spawn('node', ['cli.js', '-o=electron.d.ts'], {
1622
cwd: path.resolve(__dirname, '..')
1723
}).on('exit', () => done())
24+
done()
1825
})
1926

2027
it('should output a electron.d.ts file', () => {
@@ -23,18 +30,20 @@ describe('Definition File', function () {
2330
})
2431

2532
it('should correctly output all exported Electron modules', () => {
26-
const AllElectron = output.match(/AllElectron {([\s\S]+?)}/)
27-
expect(AllElectron).to.be.an('array')
28-
const AllElectronModules = AllElectron[1].split(';').map(l => l.trim())
33+
const AllElectronModules = getDefinitionsForInterface('MainInterface').concat(
34+
getDefinitionsForInterface('CommonInterface'),
35+
getDefinitionsForInterface('RendererInterface')
36+
)
2937
const knownElectronModules = ['clipboard', 'app', 'autoUpdater', 'dialog', 'ipcMain', 'Menu', 'MenuItem', 'webContents', 'BrowserWindow']
3038
knownElectronModules.forEach(knownModule => expect(AllElectronModules.some(tModule => tModule.indexOf(knownModule) === 0)).to.equal(true))
3139
})
3240

3341
it('should not output classes that are not exported Electron modules', () => {
34-
const AllElectron = output.match(/AllElectron {([\s\S]+?)}/)
35-
expect(AllElectron).to.be.an('array')
36-
const AllElectronModules = AllElectron[1].split(';').map(l => l.trim())
42+
const AllElectronModules = getDefinitionsForInterface('MainInterface').concat(
43+
getDefinitionsForInterface('CommonInterface'),
44+
getDefinitionsForInterface('RendererInterface')
45+
)
3746
const unKnownElectronModules = ['Clipboard', 'CrashReport', 'WebContents', 'menu', 'Session']
38-
unKnownElectronModules.forEach(knownModule => expect(AllElectronModules.some(tModule => tModule.indexOf(knownModule) === 0)).to.equal(false))
47+
unKnownElectronModules.forEach(knownModule => expect(AllElectronModules.some(tModule => tModule.indexOf(knownModule) === 0)).to.equal(false, knownModule))
3948
})
4049
})

0 commit comments

Comments
 (0)