From d86059b81134c2681bc59b86948ab0ea147c0329 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 17 Oct 2012 13:22:41 +0200 Subject: [PATCH] More preparations for qunit testing. --- 4chan_x.user.js | 34 ++++++++++++++++++++++++++++++++++ grunt.js | 17 +++++++++-------- src/main.coffee | 37 +++++++++++++++++++++++++++++++++++++ test/index.html | 1 + 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d6033baa3..674deb1f4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2571,6 +2571,10 @@ val = Conf[key]; Conf[key] = $.get(key, val); } + if (QUnit) { + Main.initQUnit(); + return; + } pathname = location.pathname.split('/'); g.BOARD = new Board(pathname[1]); if (g.REPLY = pathname[2] === 'res') { @@ -2595,6 +2599,36 @@ }); } }, + initQUnit: function() { + window.x = { + UI: UI, + $: $, + Board: Board, + Thread: Thread, + Post: Post, + Main: Main, + Redirect: Redirect, + Build: Build, + Get: Get, + Quotify: Quotify, + QuoteInline: QuoteInline, + QuotePreview: QuotePreview, + QuoteBacklink: QuoteBacklink, + QuoteOP: QuoteOP, + QuoteCT: QuoteCT, + Anonymize: Anonymize, + Time: Time, + FileInfo: FileInfo, + Sauce: Sauce, + RevealSpoilers: RevealSpoilers, + AutoGIF: AutoGIF, + ImageHover: ImageHover, + ThreadUpdater: ThreadUpdater + }; + g.BOARD = new Board('a'); + g.REPLY = true; + return g.THREAD = '123456789'; + }, initHeader: function() { $.addStyle(Main.css); Main.header = $.el('div', { diff --git a/grunt.js b/grunt.js index 2ca31c187..c5c392104 100644 --- a/grunt.js +++ b/grunt.js @@ -24,7 +24,7 @@ module.exports = function(grunt) { ], dest: 'tmp/script.coffee' }, - js: { + script: { src: ['', '', 'tmp/script.js'], dest: '' }, @@ -38,7 +38,7 @@ module.exports = function(grunt) { } }, coffee: { - all: { + script: { src: 'tmp/script.coffee', dest: 'tmp/script.js' } @@ -46,14 +46,15 @@ module.exports = function(grunt) { exec: { commit: { command: function(grunt) { - var name, version; + var name, release, version; name = grunt.config(['pkg', 'name']).replace(/-/g, ' '); version = grunt.config(['pkg', 'version']); + release = name + ' v' + version; return [ 'git checkout master', - 'git commit -am "Release ' + name + ' v' + version + '."', - 'git tag -a ' + version + ' -m "' + version + '"', - 'git tag -af stable -m "' + version + '"' + 'git commit -am "Release ' + release + '."', + 'git tag -a ' + version + ' -m "' + release + '"', + 'git tag -af stable -m "' + release + '"' ].join(' && '); }, stdout: true @@ -91,10 +92,10 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-coffee'); grunt.loadNpmTasks('grunt-exec'); - grunt.registerTask('default', 'concat:coffee coffee concat:js clean'); + grunt.registerTask('default', 'concat:coffee coffee:script concat:script clean'); grunt.registerTask('release', 'concat:meta concat:latest default exec:commit exec:push'); grunt.registerTask('patch', 'bump'); grunt.registerTask('upgrade', 'bump:minor'); - grunt.registerTask('test', 'server qunit'); + grunt.registerTask('test', 'default server qunit'); }; diff --git a/src/main.coffee b/src/main.coffee index 699b8d5b1..c4d6cae80 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -266,6 +266,10 @@ Main = for key, val of Conf Conf[key] = $.get key, val + if QUnit + Main.initQUnit() + return + pathname = location.pathname.split '/' g.BOARD = new Board pathname[1] if g.REPLY = pathname[2] is 'res' @@ -285,6 +289,39 @@ Main = location.href = url if url return + initQUnit: -> + window.x = + # ui.coffee + UI: UI + # $.coffee + $: $ + # main.coffee + Board: Board + Thread: Thread + Post: Post + Main: Main + # features.coffee + Redirect: Redirect + Build: Build + Get: Get + Quotify: Quotify + QuoteInline: QuoteInline + QuotePreview: QuotePreview + QuoteBacklink: QuoteBacklink + QuoteOP: QuoteOP + QuoteCT: QuoteCT + Anonymize: Anonymize + Time: Time + FileInfo: FileInfo + Sauce: Sauce + RevealSpoilers: RevealSpoilers + AutoGIF: AutoGIF + ImageHover: ImageHover + ThreadUpdater: ThreadUpdater + g.BOARD = new Board 'a' + g.REPLY = true + g.THREAD = '123456789' + initHeader: -> $.addStyle Main.css Main.header = $.el 'div', diff --git a/test/index.html b/test/index.html index 63f9faf3b..0c7e5acb9 100644 --- a/test/index.html +++ b/test/index.html @@ -8,6 +8,7 @@
+