Example #1
0
 (tmpDir) => {
   const configFilePath = path.join(tmpDir.path(), 'config.js');
   fs.writeFileSync(configFilePath,
     `module.exports = {
       sourceDir: 'path/to/fake/source/dir',
     };`);
   const configObj = loadJSConfigFile(configFilePath);
   assert.equal(configObj.sourceDir, 'path/to/fake/source/dir');
 });
Example #2
0
 (tmpDir) => {
   const configFilePath = path.join(tmpDir.path(), 'config.js');
   fs.writeFileSync(configFilePath,
     // missing = in two places
     `module.exports {
         sourceDir 'path/to/fake/source/dir',
       };`);
   assert.throws(() => {
     loadJSConfigFile(configFilePath);
   }, UsageError);
 });
Example #3
0
 (tmpDir) => {
   const messageFileName = path.join(tmpDir.path(), 'messages.json');
   fs.writeFileSync(messageFileName,
     '{"simulated:" "json syntax error"');
   return getDefaultLocalizedName({
     messageFile: messageFileName,
     manifestData: manifestWithoutApps,
   })
     .then(makeSureItFails())
     .catch((error) => {
       assert.instanceOf(error, UsageError);
       assert.match(error.message, /Unexpected token '"' at 1:15/);
       assert.match(error.message, /^Error parsing messages.json/);
       assert.include(error.message, messageFileName);
     });
 }
Example #4
0
      (tmpDir) => {
        const messageFileName = path.join(tmpDir.path(), 'messages.json');
        fs.writeFileSync(messageFileName,
          `{"extensionName": {
              "message": "example extension",
              "description": "example description"
            }
          }`);

        const manifestWithRepeatingPattern = {
          name: '__MSG_extensionName__ __MSG_extensionName__',
          version: '0.0.1',
        };

        return getDefaultLocalizedName({
          messageFile: messageFileName,
          manifestData: manifestWithRepeatingPattern,
        })
          .then((result) => {
            assert.match(result, /example extension example extension/);
          });
      }
Example #5
0
 (tmpDir) => {
   const messageFileName = path.join(tmpDir.path(), 'messages.json');
   //This is missing the 'message' key
   fs.writeFileSync(messageFileName,
     `{"extensionName": {
         "description": "example extension"
         }
     }`);
   const basicLocalizedManifest = {
     name: '__MSG_extensionName__',
     version: '0.0.1',
   };
   return getDefaultLocalizedName({
     messageFile: messageFileName,
     manifestData: basicLocalizedManifest,
   })
     .then(makeSureItFails())
     .catch((error) => {
       assert.instanceOf(error, UsageError);
       assert.match(
         error.message,
         /The locale file .*messages\.json is missing key: extensionName/);
     });
 }
Example #6
0
 (tmpDir) => {
   const configFilePath = path.join(tmpDir.path(), 'config.js');
   fs.writeFileSync(configFilePath, '{};');
   loadJSConfigFile(configFilePath);
 });