Skip to content
Browse files

Remove duplicate resp code by creating a generic "get_resp" funciton.

  • Loading branch information...
1 parent 894cd11 commit f2ec7c64e3bb43073282257d445fc2d0a3c83ede @shane-tomlinson shane-tomlinson committed Jan 27, 2013
Showing with 22 additions and 56 deletions.
  1. +22 −56 test/connect-cachify-test.js
View
78 test/connect-cachify-test.js
@@ -21,6 +21,23 @@ var make_assets = function () { return {
"/js/font-loader.js#with_fragment_id"
]}; };
+function get_resp() {
+ return {
+ state: {},
+ local: function (key, value) {
+ this.state[key] = value;
+ },
+ setHeader: function (key, value) {
+ this.state[key] = value;
+ if (!this.state['header']) this.state['header'] = 0;
+ this.state['header'] += 1;
+ },
+ on: function (name, cb) {
+
+ }
+ };
+}
+
exports.setup = nodeunit.testCase({
setUp: function (cb) {
resetConfig();
@@ -104,20 +121,7 @@ exports.setup = nodeunit.testCase({
req = {
url: '/d41d8cd98f/js/main.min.js'
},
- resp = {
- state: {},
- local: function (key, value) {
- this.state[key] = value;
- },
- setHeader: function (key, value) {
- this.state[key] = value;
- if (!this.state['header']) this.state['header'] = 0;
- this.state['header'] += 1;
- },
- on: function (name, cb) {
-
- }
- },
+ resp = get_resp(),
mddlwr;
mddlwr = cachify.setup(assets, {
root: '/tmp',
@@ -153,20 +157,7 @@ exports.setup = nodeunit.testCase({
req = {
url: '/d41d8cd98f/js/main.min.js'
},
- resp = {
- state: {},
- local: function (key, value) {
- this.state[key] = value;
- },
- setHeader: function (key, value) {
- this.state[key] = value;
- if (!this.state['header']) this.state['header'] = 0;
- this.state['header'] += 1;
- },
- on: function (name, cb) {
-
- }
- },
+ resp = get_resp(),
mddlwr;
mddlwr = cachify.setup(
assets, {
@@ -194,20 +185,7 @@ exports.setup = nodeunit.testCase({
req = {
url: '/v/d41d8cd98f/js/main.min.js'
},
- resp = {
- state: {},
- local: function (key, value) {
- this.state[key] = value;
- },
- setHeader: function (key, value) {
- this.state[key] = value;
- if (!this.state['header']) this.state['header'] = 0;
- this.state['header'] += 1;
- },
- on: function (name, cb) {
-
- }
- },
+ resp = get_resp(),
mddlwr;
mddlwr = cachify.setup(
assets, {
@@ -236,21 +214,9 @@ exports.setup = nodeunit.testCase({
req = {
url: '/cachify/d41d8cd98f/other'
},
- resp = {
- state: {},
- local: function (key, value) {
- this.state[key] = value;
- },
- setHeader: function (key, value) {
- this.state[key] = value;
- if (!this.state['header']) this.state['header'] = 0;
- this.state['header'] += 1;
- },
- on: function (name, cb) {
-
- }
- },
+ resp = get_resp(),
mddlwr;
+
mddlwr = cachify.setup(
assets, {
prefix: 'cachify',

0 comments on commit f2ec7c6

Please sign in to comment.
Something went wrong with that request. Please try again.