Start adding a real unit test framework.
This commit is contained in:
		| @@ -10,5 +10,10 @@ | |||||||
|   "boss": true, |   "boss": true, | ||||||
|   "eqnull": true, |   "eqnull": true, | ||||||
|   "node": true, |   "node": true, | ||||||
|   "white": true |   "white": true, | ||||||
|  |   "predef": [ | ||||||
|  |     "describe", | ||||||
|  |     "it", | ||||||
|  |     "before" | ||||||
|  |   ] | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,18 +1,28 @@ | |||||||
| module.exports = (grunt) -> | module.exports = (grunt) -> | ||||||
|     @loadNpmTasks('grunt-contrib-jshint') |     @loadNpmTasks('grunt-contrib-jshint') | ||||||
|     @loadNpmTasks('grunt-contrib-watch') |     @loadNpmTasks('grunt-contrib-watch') | ||||||
|  |     @loadNpmTasks('grunt-mocha-cli') | ||||||
|  |  | ||||||
|     @initConfig |     @initConfig | ||||||
|         jshint: |         jshint: | ||||||
|             all: [ 'lib/*.js' ] |             all: [ 'lib/*.js', 'test/*.js' ] | ||||||
|             options: |             options: | ||||||
|                 jshintrc: '.jshintrc' |                 jshintrc: '.jshintrc' | ||||||
|  |  | ||||||
|         watch: |         watch: | ||||||
|             all: |             all: | ||||||
|                 files: ['lib/**.js', 'test/*/*'] |                 options: | ||||||
|  |                     atBegin: true | ||||||
|  |                 files: ['lib/**.js', 'test/*{,/*}'] | ||||||
|                 tasks: ['test'] |                 tasks: ['test'] | ||||||
|  |  | ||||||
|  |         mochacli: | ||||||
|  |             options: | ||||||
|  |                 files: 'test/*.js' | ||||||
|  |             spec: | ||||||
|  |                 options: | ||||||
|  |                     reporter: 'spec' | ||||||
|  |  | ||||||
|     @registerTask 'default', ['test'] |     @registerTask 'default', ['test'] | ||||||
|     @registerTask 'build', ['jshint'] |     @registerTask 'build', ['jshint'] | ||||||
|     @registerTask 'test', ['build'] |     @registerTask 'test', ['build', 'mochacli'] | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "grunt": "~0.4.2", |     "grunt": "~0.4.2", | ||||||
|     "grunt-contrib-watch": "~0.5.3", |     "grunt-contrib-watch": "~0.5.3", | ||||||
|     "grunt-contrib-jshint": "~0.7.2" |     "grunt-contrib-jshint": "~0.7.2", | ||||||
|  |     "grunt-mocha-cli": "~1.4.0" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										287
									
								
								test/fixtures/big.po
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								test/fixtures/big.po
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,287 @@ | |||||||
|  | # French translation of Link (6.x-2.9) | ||||||
|  | # Copyright (c) 2011 by the French translation team | ||||||
|  | # | ||||||
|  | msgid "" | ||||||
|  | msgstr "" | ||||||
|  | "Project-Id-Version: Link (6.x-2.9)\n" | ||||||
|  | "POT-Creation-Date: 2011-12-31 23:39+0000\n" | ||||||
|  | "PO-Revision-Date: 2013-12-17 14:21+0100\n" | ||||||
|  | "Language-Team: French\n" | ||||||
|  | "MIME-Version: 1.0\n" | ||||||
|  | "Content-Type: text/plain; charset=UTF-8\n" | ||||||
|  | "Content-Transfer-Encoding: 8bit\n" | ||||||
|  | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||||||
|  | "Last-Translator: Ruben Vermeersch <ruben@rocketeer.be>\n" | ||||||
|  | "Language: fr\n" | ||||||
|  | "X-Generator: Poedit 1.6.2\n" | ||||||
|  |  | ||||||
|  | msgid "Title" | ||||||
|  | msgstr "Titre" | ||||||
|  |  | ||||||
|  | msgid "CCK" | ||||||
|  | msgstr "CCK" | ||||||
|  |  | ||||||
|  | msgid "Content" | ||||||
|  | msgstr "Contenu" | ||||||
|  |  | ||||||
|  | msgid "Link" | ||||||
|  | msgstr "Lien" | ||||||
|  |  | ||||||
|  | msgid "Link Target" | ||||||
|  | msgstr "Cible du Lien" | ||||||
|  |  | ||||||
|  | msgid "URL" | ||||||
|  | msgstr "URL" | ||||||
|  |  | ||||||
|  | msgid "Placeholder tokens" | ||||||
|  | msgstr "Jetons (tokens) de substitution" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "The following placeholder tokens can be used in both paths and titles. When " | ||||||
|  | "used in a path or title, they will be replaced with the appropriate values." | ||||||
|  | msgstr "" | ||||||
|  | "Les ébauches de jetons suivantes peuvent être utilisées à la fois dans les " | ||||||
|  | "chemins et dans les titres. Lorsqu'elles sont utilisées dans un chemin ou un " | ||||||
|  | "titre, elles seront remplacées par les valeurs appropriées." | ||||||
|  |  | ||||||
|  | msgid "Optional Title" | ||||||
|  | msgstr "Titre Optionnel" | ||||||
|  |  | ||||||
|  | msgid "Required Title" | ||||||
|  | msgstr "Titre Obligatoire" | ||||||
|  |  | ||||||
|  | msgid "No Title" | ||||||
|  | msgstr "Aucun Titre" | ||||||
|  |  | ||||||
|  | msgid "Link Title" | ||||||
|  | msgstr "Titre du Lien" | ||||||
|  |  | ||||||
|  | msgid "URL Display Cutoff" | ||||||
|  | msgstr "Coupure de l'Affichage de l'URL" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "If the user does not include a title for this link, the URL will be used as " | ||||||
|  | "the title. When should the link title be trimmed and finished with an " | ||||||
|  | "elipsis (…)? Leave blank for no limit." | ||||||
|  | msgstr "" | ||||||
|  | "Si l'utilisateur n'inclue pas de titre pour ce lien, l'URL sera utilisée en " | ||||||
|  | "tant que titre. A quel endroit le lien devra-t-il être coupé et terminé par " | ||||||
|  | "une ellipse (…) ? Laissez vide pour aucune limite." | ||||||
|  |  | ||||||
|  | msgid "Default (no target attribute)" | ||||||
|  | msgstr "Par Défaut (aucun attribut de cible)" | ||||||
|  |  | ||||||
|  | msgid "Open link in window root" | ||||||
|  | msgstr "Ouvrir le lien dans la fenêtre courante" | ||||||
|  |  | ||||||
|  | msgid "Open link in new window" | ||||||
|  | msgstr "Ouvrir le lien dans une nouvelle fenêtre" | ||||||
|  |  | ||||||
|  | msgid "Allow the user to choose" | ||||||
|  | msgstr "Autoriser l'utilisateur à choisir" | ||||||
|  |  | ||||||
|  | msgid "Additional CSS Class" | ||||||
|  | msgstr "Classe CSS additionnelle" | ||||||
|  |  | ||||||
|  | msgid "Not a valid URL." | ||||||
|  | msgstr "Cette URL n'est pas valide." | ||||||
|  |  | ||||||
|  | msgid "Titles are required for all links." | ||||||
|  | msgstr "Les titres sont obligatoires pour tous les liens." | ||||||
|  |  | ||||||
|  | msgid "Open URL in a New Window" | ||||||
|  | msgstr "Ouvril l'URL dans une Nouvelle Fenêtre" | ||||||
|  |  | ||||||
|  | msgid "Defines simple link field types." | ||||||
|  | msgstr "Définit les types de champs \"lien simple\"." | ||||||
|  |  | ||||||
|  | msgid "Link URL" | ||||||
|  | msgstr "Url du Lien" | ||||||
|  |  | ||||||
|  | msgid "Wildcard" | ||||||
|  | msgstr "Joker" | ||||||
|  |  | ||||||
|  | msgid "=" | ||||||
|  | msgstr "=" | ||||||
|  |  | ||||||
|  | msgid "Protocol" | ||||||
|  | msgstr "Protocole" | ||||||
|  |  | ||||||
|  | msgid "Optional URL" | ||||||
|  | msgstr "URL optionnelle" | ||||||
|  |  | ||||||
|  | msgid "Static Title: " | ||||||
|  | msgstr "Titre Statique : " | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "If the link title is optional or required, a field will be displayed to the " | ||||||
|  | "end user. If the link title is static, the link will always use the same " | ||||||
|  | "title. If <a href=\"http://drupal.org/project/token\">token module</a> is " | ||||||
|  | "installed, the static title value may use any other node field as its value. " | ||||||
|  | "Static and token-based titles may include most inline XHTML tags such as " | ||||||
|  | "<em>strong</em>, <em>em</em>, <em>img</em>, <em>span</em>, etc." | ||||||
|  | msgstr "" | ||||||
|  | "Si le titre du lien est facultatif ou obligatoire, un champ sera affiché à " | ||||||
|  | "l'utilisateur final. Si le titre du lien est statique, le lien utilisera " | ||||||
|  | "toujours le même titre. Si le <a href=\"http://drupal.org/project/token" | ||||||
|  | "\">module token</a> est installé, le titre statique peut utiliser n'importe " | ||||||
|  | "quel autre champ du nœud pour sa valeur. Les titres statiques et basés sur " | ||||||
|  | "des jetons (tokens) peuvent contenir la plupart des balises XHTML en ligne, " | ||||||
|  | "telles que <em>strong</em>, <em>em</em>, <em>img</em>, <em>span</em>, etc." | ||||||
|  |  | ||||||
|  | msgid "Allow user-entered tokens" | ||||||
|  | msgstr "Autoriser les jetons (tokens) saisis par l'utilisateur" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "Checking will allow users to enter tokens in URLs and Titles on the node " | ||||||
|  | "edit form. This does not affect the field settings on this page." | ||||||
|  | msgstr "" | ||||||
|  | "Le fait de cocher cette case permettra aux utilisateurs de saisir des jetons " | ||||||
|  | "dans les URL et les Titres dans le formulaire d'édition du nœud. Ceci " | ||||||
|  | "n'affecte pas les configurations de champ sur cette page." | ||||||
|  |  | ||||||
|  | msgid "Rel Attribute" | ||||||
|  | msgstr "Attribut Rel" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "When output, this link will have this rel attribute. The most common usage " | ||||||
|  | "is <a href=\"http://en.wikipedia.org/wiki/Nofollow\">rel="nofollow"" | ||||||
|  | "</a> which prevents some search engines from spidering entered links." | ||||||
|  | msgstr "" | ||||||
|  | "Quand il sera affiché, ce lien aura cet attribut rel. L'usage le plus commun " | ||||||
|  | "est <a href=\"http://fr.wikipedia.org/wiki/Nofollow\">rel="" | ||||||
|  | "nofollow"</a> qui empêche certains moteurs de recherche d'aspirer les " | ||||||
|  | "liens suivis." | ||||||
|  |  | ||||||
|  | msgid "A default title must be provided if the title is a static value" | ||||||
|  | msgstr "" | ||||||
|  | "Un titre pas défaut doit être fourni si le titre est une valeur statique" | ||||||
|  |  | ||||||
|  | msgid "At least one title or URL must be entered." | ||||||
|  | msgstr "Vous devez saisir au moins un titre ou une URL." | ||||||
|  |  | ||||||
|  | msgid "You cannot enter a title without a link url." | ||||||
|  | msgstr "Vous ne pouvez pas saisir un titre dans une url de lien." | ||||||
|  |  | ||||||
|  | msgid "Title, as link (default)" | ||||||
|  | msgstr "Titre, en tant que lien (par défaut)" | ||||||
|  |  | ||||||
|  | msgid "URL, as link" | ||||||
|  | msgstr "URL, en tant que lien" | ||||||
|  |  | ||||||
|  | msgid "Short, as link with title \"Link\"" | ||||||
|  | msgstr "Court, comme lien avec le titre \"Lien\"" | ||||||
|  |  | ||||||
|  | msgid "Label, as link with label as title" | ||||||
|  | msgstr "Étiquette, comme lien avec l'étiquette comme titre" | ||||||
|  |  | ||||||
|  | msgid "Separate title and URL" | ||||||
|  | msgstr "Titre et URL séparés" | ||||||
|  |  | ||||||
|  | msgid "Validator" | ||||||
|  | msgstr "Validateur" | ||||||
|  |  | ||||||
|  | msgid "Is one of" | ||||||
|  | msgstr "Fait partie de" | ||||||
|  |  | ||||||
|  | msgid "@label title" | ||||||
|  | msgstr "Titre de @label" | ||||||
|  |  | ||||||
|  | msgid "@label protocol" | ||||||
|  | msgstr "Protocole de @label" | ||||||
|  |  | ||||||
|  | msgid "@label target" | ||||||
|  | msgstr "Cible de @label" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "The title to use when this argument is present; it will override the title " | ||||||
|  | "of the view and titles from previous arguments. You can use percent " | ||||||
|  | "substitution here to replace with argument titles. Use \"%1\" for the first " | ||||||
|  | "argument, \"%2\" for the second, etc." | ||||||
|  | msgstr "" | ||||||
|  | "Le titre à utiliser lorsque cet argument est présent ; il écrasera le titre " | ||||||
|  | "de la vue et les titres provenant des arguments précédents. Vous pouvez " | ||||||
|  | "utiliser ici les substitutions de pourcentage pour remplacer avec les titres " | ||||||
|  | "des arguments. Utilisez \"%1\" pour le premier argument, \"%2\" pour le " | ||||||
|  | "second, etc." | ||||||
|  |  | ||||||
|  | msgid "Action to take if argument is not present" | ||||||
|  | msgstr "Action à mener si l'argument est absent" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "If this value is received as an argument, the argument will be ignored; i.e, " | ||||||
|  | "\"all values\"" | ||||||
|  | msgstr "" | ||||||
|  | "Si cette valeur est reçue comme argument, l'argument sera ignoré ; " | ||||||
|  | "correspond à \"toutes les valeurs\"" | ||||||
|  |  | ||||||
|  | msgid "Wildcard title" | ||||||
|  | msgstr "Titre du joker" | ||||||
|  |  | ||||||
|  | msgid "The title to use for the wildcard in substitutions elsewhere." | ||||||
|  | msgstr "" | ||||||
|  | "Le titre à utiliser pour le joker dans les substitutions partout ailleurs." | ||||||
|  |  | ||||||
|  | msgid "<Basic validation>" | ||||||
|  | msgstr "<Validation basique>" | ||||||
|  |  | ||||||
|  | msgid "Action to take if argument does not validate" | ||||||
|  | msgstr "Actions à mener si l'argument ne passe pas la validation" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "The protocols displayed here are those globally available. You may add more " | ||||||
|  | "protocols by modifying the <em>filter_allowed_protocols</em> variable in " | ||||||
|  | "your installation." | ||||||
|  | msgstr "" | ||||||
|  | "Les protocoles affichés ici sont ceux disponibles de manière globale. Vous " | ||||||
|  | "pouvez ajouter plus de protocoles en modifiant la variable " | ||||||
|  | "<em>filter_allowed_protocols</em> de votre installation." | ||||||
|  |  | ||||||
|  | msgid "Link title" | ||||||
|  | msgstr "Titre du lien" | ||||||
|  |  | ||||||
|  | msgid "exposed" | ||||||
|  | msgstr "exposé" | ||||||
|  |  | ||||||
|  | msgid "Formatted html link" | ||||||
|  | msgstr "Lien html formaté" | ||||||
|  |  | ||||||
|  | msgid "Store a title, href, and attributes in the database to assemble a link." | ||||||
|  | msgstr "" | ||||||
|  | "Stocker un titre, href et des attributs dans la base de données pour les " | ||||||
|  | "assembler dans un lien." | ||||||
|  |  | ||||||
|  | msgid "URL, as plain text" | ||||||
|  | msgstr "URL, texte simple" | ||||||
|  |  | ||||||
|  | msgid "@label URL" | ||||||
|  | msgstr "URL de @label" | ||||||
|  |  | ||||||
|  | msgid "Validate URL" | ||||||
|  | msgstr "Valider l'URL" | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "If checked, the URL field will be verified as a valid URL during validation." | ||||||
|  | msgstr "" | ||||||
|  | "Si coché, la validité du format de l'URL sera verifiée durant la validation." | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "If checked, the URL field is optional and submitting a title alone will be " | ||||||
|  | "acceptable. If the URL is omitted, the title will be displayed as plain text." | ||||||
|  | msgstr "" | ||||||
|  | "Si coché, le champ URL est optionnel and soumettre un titre seul sera " | ||||||
|  | "accepté. SI l'URL est omise, le titre sera affiché en texte brut." | ||||||
|  |  | ||||||
|  | msgid "" | ||||||
|  | "When output, this link will have this class attribute. Multiple classes " | ||||||
|  | "should be separated by spaces." | ||||||
|  | msgstr "" | ||||||
|  | "Lors de l'affichage, le lien aura cet attribut de classe (class). Les " | ||||||
|  | "classes doivent être séparées par des espaces." | ||||||
|  |  | ||||||
|  | msgid "Link 'title' Attribute" | ||||||
|  | msgstr "Attribut 'title' du lien" | ||||||
|  |  | ||||||
|  | # Comment | ||||||
|  | msgid "Title, as plain text" | ||||||
|  | msgstr "Attribut title, en tant que texte brut" | ||||||
							
								
								
									
										30
									
								
								test/headers.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								test/headers.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | |||||||
|  | var assert = require('assert'); | ||||||
|  | var PO = require('..'); | ||||||
|  |  | ||||||
|  | describe('Headers', function () { | ||||||
|  |     var po; | ||||||
|  |  | ||||||
|  |     before(function (done) { | ||||||
|  |         PO.load(__dirname + '/fixtures/big.po', function (err, result) { | ||||||
|  |             assert.equal(err, null); | ||||||
|  |             po = result; | ||||||
|  |             done(); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     it('Parses the po file', function () { | ||||||
|  |         assert.notEqual(po, null); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     it('Parses headers correctly', function () { | ||||||
|  |         assert.equal(po.headers['Project-Id-Version'], 'Link (6.x-2.9)'); | ||||||
|  |         assert.equal(po.headers['MIME-Version'], '1.0'); | ||||||
|  |         assert.equal(po.headers['Plural-Forms'], 'nplurals=2; plural=(n > 1);'); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     it('Parses all headers', function () { | ||||||
|  |         // There are 11 headers in the .po file, but some default headers | ||||||
|  |         // are defined (nr. 12 in this case is Report-Msgid-Bugs-To). | ||||||
|  |         assert.equal(Object.keys(po.headers).length, 12); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
		Reference in New Issue
	
	Block a user