Skip to content

Commit

Permalink
A place to start
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Feb 24, 2014
0 parents commit 733c63f
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
@@ -0,0 +1,20 @@
*.iml
.idea

target

lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

npm-debug.log
node_modules
38 changes: 38 additions & 0 deletions .jshintrc
@@ -0,0 +1,38 @@
{
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
"curly": true, // Require {} for every new block or scope.
"eqeqeq": true, // Require triple equals i.e. `===`.
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef": true, // Prohibit variable use before definition.
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"quotmark": "single", // Define quotes to string values.
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
"undef": true, // Require all non-global variables be declared before they are used.
"unused": true, // Warn unused variables.
"strict": true, // Require `use strict` pragma in every file.
"trailing": true, // Prohibit trailing whitespaces.
"smarttabs": false, // Suppresses warnings about mixed tabs and spaces
"predef": [ // Extra globals.
"angular",
"define",
"require",
"exports",
"module",
"describe",
"xdescribe",
"before",
"beforeEach",
"after",
"afterEach",
"it",
"xit",
"inject"
],
"indent": 4, // Specify indentation spacing
"devel": true, // Allow development statements e.g. `console.log();`.
"noempty": true // Prohibit use of empty blocks.
}
32 changes: 32 additions & 0 deletions README.md
@@ -0,0 +1,32 @@
# Test-Driven Tuesday

## Postcode exercise

The postcodes are **alphanumeric** and **between six and eight characters long**,
including a **single space separating the outward and inward** parts of the code.
Each postcode unit generally represents a street, part of a street, or a single address. *[...]*

The **'outward'** part identifies first the **postcode area**, using **one or two letters** (for example L for Liverpool, RH Redhill and EH Edinburgh).
These letter(s) are **followed by one or two digits** (and **sometimes a final letter**) to identify the appropriate postcode district (for example W1A, RH1, RH10 or SE1P). *[...]*

The **'inward'** is used to assist with the delivery of post within a postal district.
The **first character is a number** denoting a 'sector' and the **final two letters** identify the postcode unit,
which may be a group of properties, a single property, a sub-section of the property,
an individual organisation or a subsection of the organisation. The level of discrimination is often based on the amount of mail received by the premises or business. *[...]*

### Validation

The format is as follows, where **A signifies a letter and 9 a digit**:

| Format | Example |
|----------|----------|
| AA9A 9AA | EC1A 1BB |
| A9A 9AA | W1A 1HQ |
| A9 9AA | M1 1AA |
| A99 9AA | B33 8TH |
| AA9 9AA | CR2 6XH |
| AA99 9AA | DN55 1PT |

source: [Wikipedia](http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom)

*Postcode exercise has been originally designed by [Antony Marcano](http://antonymarcano.com/blog/)*
66 changes: 66 additions & 0 deletions gruntfile.js
@@ -0,0 +1,66 @@
'use strict';

module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-cov');

grunt.registerTask('default', ['jshint', 'test']);
grunt.registerTask('test', ['mochacov:watch']);
grunt.registerTask('coverage', ['mochacov:report']);


grunt.registerTask('timestamp', function() {
grunt.log.subhead(new Date());
});

grunt.initConfig({

src: {
js: ['src/**/*.js'],
specs: ['spec/**/*.js']
},

target: 'target',


clean: [ '<%= target %>' ],

jshint: {
src: [ '<%= src.js %>', '<%= src.specs %>'],
options: {
jshintrc: true
}
},

watch: {
options: {
spawn: true
},
files: [
'gruntfile.js',
'<%= src.js %>',
'<%= src.specs %>'
],
tasks: [ 'clean', 'default']
},

mochacov: {
options: {
files: '<%= src.specs %>'
},
watch: {
options: {
reporter: 'spec'
}
},
report: {
options: {
reporter: 'html-cov',
output: '<%= target %>/coverage.html'
}
}
}
});
};
34 changes: 34 additions & 0 deletions package.json
@@ -0,0 +1,34 @@
{
"name": "test-driven-tuesday",
"description": "The basics of growing JavaScript applications",
"author": "Jan Molak <jan.molak@smartcodeltd.co.uk>",
"license": "MIT",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "https://github.com/jan-molak/test-driven-tuesday.git"
},
"dependencies" : {

},
"devDependencies": {
"chai": "1.9.0",
"grunt": "0.4.2",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-jshint": "0.8.0",
"grunt-contrib-watch": "0.5.3",
"grunt-mocha-cov": "0.2.1",
"rewire": "2.0.0"
},
"scripts": {
"blanket": {
"pattern": [
"src"
],
"data-cover-never": [
"spec"
]
}
}
}
27 changes: 27 additions & 0 deletions spec/postcode.spec.js
@@ -0,0 +1,27 @@
'use strict';

var expect = require('chai').expect,

Postcode = require('../src/postcode');

describe('Postcode', function() {

it('is instantiated with a string representing a post code', function() {
// prepare

// expect

// act
var postcode = new Postcode('E14 5EP');

// assert
expect(postcode).to.be.an('object');
});

describe('a valid post code', function() {

xit('...', function() {
});
});

});
1 change: 1 addition & 0 deletions src/postcode.js
@@ -0,0 +1 @@
module.exports = undefined;

0 comments on commit 733c63f

Please sign in to comment.