From c32cde989b07674db4b7007e531aa536c01d52e2 Mon Sep 17 00:00:00 2001 From: Matthew Riley MacPherson Date: Thu, 8 Oct 2015 22:27:05 +0100 Subject: [PATCH] Improve scanFile test --- tests/test.rdf.js | 2 +- tests/test.validator.js | 17 ++++++++++++++--- tests/test.validators.javascript.js | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test.rdf.js b/tests/test.rdf.js index 105f976f..614d6c73 100644 --- a/tests/test.rdf.js +++ b/tests/test.rdf.js @@ -17,7 +17,7 @@ function validRDF(contents) { `; } -describe('RDF Checker', function() { +describe('RDF', function() { it('should not warn when we validate a good RDF file', () => { var contents = fs.readFileSync('tests/example.rdf', 'utf8'); diff --git a/tests/test.validator.js b/tests/test.validator.js index 381c81ca..b0d1a6d8 100644 --- a/tests/test.validator.js +++ b/tests/test.validator.js @@ -112,15 +112,26 @@ describe('Validator', function() { }); }); - // Test to make sure we can all JS files inside an add-on, not just one. - it('should scan all JS files', () => { + // Test to make sure we can all files inside an add-on, not just one of each. + // + // Uses our test XPI, with the following file layout: + // + // - chrome.manifest + // - chrome/ + // - components/ + // - main.js (has a mozIndexedDB assignment) + // - secondary.js (nothing bad) + // - install.rdf + it('should scan all files', () => { var addonValidator = new Validator({_: ['tests/example.xpi']}); var getFileSpy = sinon.spy(addonValidator, 'scanFile'); return addonValidator.scan() .then(() => { - assert.ok(getFileSpy.calledTwice); + assert.ok(getFileSpy.calledWith('components/main.js')); + assert.ok(getFileSpy.calledWith('components/secondary.js')); + assert.ok(getFileSpy.calledWith('install.rdf')); }); }); diff --git a/tests/test.validators.javascript.js b/tests/test.validators.javascript.js index d957207c..229a3d52 100644 --- a/tests/test.validators.javascript.js +++ b/tests/test.validators.javascript.js @@ -4,7 +4,7 @@ import * as messages from 'messages'; import { singleLineString } from 'utils'; -describe('JS Code Checker', function() { +describe('JavaScript', function() { it('should not allow mozIndexedDB', () => { var code = 'var myDatabase = indexeddb || mozIndexedDB;';