Where possible, move test functionality into Test.coffee. #829
This commit is contained in:
parent
e58eefc5e6
commit
5d0d957389
3
Makefile
3
Makefile
@ -45,11 +45,8 @@ sources := $(foreach d,$(source_directories),$(call sort_directory,$(d)))
|
|||||||
|
|
||||||
uses_tests_enabled := \
|
uses_tests_enabled := \
|
||||||
src/classes/Post.coffee \
|
src/classes/Post.coffee \
|
||||||
src/site/SW.tinyboard.coffee \
|
|
||||||
src/General/Test.coffee \
|
src/General/Test.coffee \
|
||||||
src/Linkification/Linkify.coffee \
|
src/Linkification/Linkify.coffee \
|
||||||
src/Miscellaneous/Keybinds.coffee \
|
|
||||||
src/Monitoring/Unread.coffee \
|
|
||||||
src/main/Main.coffee
|
src/main/Main.coffee
|
||||||
|
|
||||||
imports_src/globals/globals.js := \
|
imports_src/globals/globals.js := \
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
<% if (readJSON('/.tests_enabled')) { %>
|
<% if (readJSON('/.tests_enabled')) { %>
|
||||||
Test =
|
Test =
|
||||||
init: ->
|
init: ->
|
||||||
return if !Conf['Menu'] or g.VIEW not in ['index', 'thread']
|
return unless g.SITE.software is 'yotsuba' and g.VIEW in ['index', 'thread']
|
||||||
|
|
||||||
a = $.el 'a',
|
if Conf['Menu']
|
||||||
textContent: 'Test HTML building'
|
a = $.el 'a',
|
||||||
$.on a, 'click', @cb.testOne
|
textContent: 'Test HTML building'
|
||||||
Menu.menu.addEntry
|
$.on a, 'click', @cb.testOne
|
||||||
el: a
|
Menu.menu.addEntry
|
||||||
open: (post) ->
|
el: a
|
||||||
a.dataset.fullID = post.fullID
|
open: (post) ->
|
||||||
true
|
a.dataset.fullID = post.fullID
|
||||||
|
true
|
||||||
|
|
||||||
a2 = $.el 'a',
|
a2 = $.el 'a',
|
||||||
textContent: 'Test HTML building'
|
textContent: 'Test HTML building'
|
||||||
@ -18,6 +19,15 @@ Test =
|
|||||||
Header.menu.addEntry
|
Header.menu.addEntry
|
||||||
el: a2
|
el: a2
|
||||||
|
|
||||||
|
if Unread.posts
|
||||||
|
testOrderLink = $.el 'a',
|
||||||
|
textContent: 'Test Post Order'
|
||||||
|
$.on testOrderLink, 'click', @cb.testOrder
|
||||||
|
Header.menu.addEntry
|
||||||
|
el: testOrderLink
|
||||||
|
|
||||||
|
$.on d, 'keydown', @cb.keydown
|
||||||
|
|
||||||
assert: (condition) ->
|
assert: (condition) ->
|
||||||
unless condition()
|
unless condition()
|
||||||
new Notice 'warning', "Assertion failed: #{condition}", 30
|
new Notice 'warning', "Assertion failed: #{condition}", 30
|
||||||
@ -137,4 +147,26 @@ Test =
|
|||||||
testAll: ->
|
testAll: ->
|
||||||
Test.testAll()
|
Test.testAll()
|
||||||
Header.menu.close()
|
Header.menu.close()
|
||||||
|
|
||||||
|
testOrder: ->
|
||||||
|
list1 = (x.ID for x in Unread.order.order())
|
||||||
|
list2 = (+x.id.match(/\d*$/)[0] for x in $$ (if g.SITE.isOPContainerThread then "#{g.SITE.selectors.thread}, " else '') + g.SITE.selectors.postContainer)
|
||||||
|
pass = do ->
|
||||||
|
return false unless list1.length is list2.length
|
||||||
|
for i in [0...list1.length] by 1
|
||||||
|
return false if list1[i] isnt list2[i]
|
||||||
|
true
|
||||||
|
if pass
|
||||||
|
new Notice 'success', "Orders same (#{list1.length} posts)", 5
|
||||||
|
else
|
||||||
|
new Notice 'warning', 'Orders differ.', 30
|
||||||
|
c.log list1
|
||||||
|
c.log list2
|
||||||
|
|
||||||
|
keydown: (e) ->
|
||||||
|
return unless Keybinds.keyCode(e) is 'v'
|
||||||
|
return if e.target.nodeName in ['INPUT', 'TEXTAREA']
|
||||||
|
Test.testAll()
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@ -218,11 +218,6 @@ Keybinds =
|
|||||||
when Conf['Next Post Quoting You']
|
when Conf['Next Post Quoting You']
|
||||||
return unless threadRoot and QuoteYou.db
|
return unless threadRoot and QuoteYou.db
|
||||||
QuoteYou.cb.seek 'following'
|
QuoteYou.cb.seek 'following'
|
||||||
<% if (readJSON('/.tests_enabled')) { %>
|
|
||||||
when 'v'
|
|
||||||
return unless threadRoot
|
|
||||||
Test.testAll()
|
|
||||||
<% } %>
|
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
@ -29,27 +29,6 @@ Unread =
|
|||||||
name: 'Unread'
|
name: 'Unread'
|
||||||
cb: @addPost
|
cb: @addPost
|
||||||
|
|
||||||
<% if (readJSON('/.tests_enabled')) { %>
|
|
||||||
testLink = $.el 'a',
|
|
||||||
textContent: 'Test Post Order'
|
|
||||||
$.on testLink, 'click', ->
|
|
||||||
list1 = (x.ID for x in Unread.order.order())
|
|
||||||
list2 = (+x.id.match(/\d*$/)[0] for x in $$ (if g.SITE.isOPContainerThread then "#{g.SITE.selectors.thread}, " else '') + g.SITE.selectors.postContainer)
|
|
||||||
pass = do ->
|
|
||||||
return false unless list1.length is list2.length
|
|
||||||
for i in [0...list1.length] by 1
|
|
||||||
return false if list1[i] isnt list2[i]
|
|
||||||
true
|
|
||||||
if pass
|
|
||||||
new Notice 'success', "Orders same (#{list1.length} posts)", 5
|
|
||||||
else
|
|
||||||
new Notice 'warning', 'Orders differ.', 30
|
|
||||||
c.log list1
|
|
||||||
c.log list2
|
|
||||||
Header.menu.addEntry
|
|
||||||
el: testLink
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
Unread.thread = @
|
Unread.thread = @
|
||||||
Unread.title = d.title
|
Unread.title = d.title
|
||||||
|
|||||||
@ -671,7 +671,8 @@ Main =
|
|||||||
['Flash Features', Flash]
|
['Flash Features', Flash]
|
||||||
['Reply Pruning', ReplyPruning]
|
['Reply Pruning', ReplyPruning]
|
||||||
['Mod Contact Links', ModContact]
|
['Mod Contact Links', ModContact]
|
||||||
<% if (readJSON('/.tests_enabled')) { %>
|
|
||||||
['Build Test', Test]
|
|
||||||
<% } %>
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
<% if (readJSON('/.tests_enabled')) { %>
|
||||||
|
Main.features.push ['Build Test', Test]
|
||||||
|
<% } %>
|
||||||
|
|||||||
@ -25,9 +25,6 @@ SW.tinyboard =
|
|||||||
'Banner'
|
'Banner'
|
||||||
'Flash Features'
|
'Flash Features'
|
||||||
'Reply Pruning'
|
'Reply Pruning'
|
||||||
<% if (readJSON('/.tests_enabled')) { %>
|
|
||||||
'Build Test'
|
|
||||||
<% } %>
|
|
||||||
]
|
]
|
||||||
|
|
||||||
detect: ->
|
detect: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user