@@ -2,6 +2,19 @@ const assert = require('assert');
22const sinon = require ( 'sinon' ) ;
33const UserVotingPermissions = require ( '../UserVotingPermissions' ) ;
44
5+ function daysAgo ( days ) {
6+ let now = new Date ( ) ;
7+ return now . getTime ( ) - days * 24 * 60 * 60 * 1000 ;
8+ }
9+
10+ function fiveDaysAgo ( ) {
11+ return daysAgo ( 5 ) ;
12+ }
13+
14+ function sixtyDaysAgo ( ) {
15+ return daysAgo ( 60 ) ;
16+ }
17+
518describe ( 'UserVotingPermissions' , function ( ) {
619 describe ( '#hasEnoughPostsToUpvote()' , function ( ) {
720 it ( 'should not throw an error when postcount is greater than the configured min posts to upvote' , async function ( ) {
@@ -67,7 +80,7 @@ describe('UserVotingPermissions', function() {
6780 } ;
6881 let db = {
6982 getSetMembers : sinon . fake . returns ( [ 'vote1' , 'vote2' ] )
70- }
83+ } ;
7184
7285 let permissions = new UserVotingPermissions ( config , db , user , post ) ;
7386 await permissions . hasVotedTooManyPostsInThread ( ) ;
@@ -82,7 +95,7 @@ describe('UserVotingPermissions', function() {
8295 } ;
8396 let db = {
8497 getSetMembers : sinon . fake . returns ( [ 'vote1' , 'vote2' , 'vote3' ] )
85- }
98+ } ;
8699
87100 let permissions = new UserVotingPermissions ( config , db , user , post ) ;
88101 try {
@@ -360,16 +373,3 @@ describe('UserVotingPermissions', function() {
360373 } ) ;
361374 } ) ;
362375} ) ;
363-
364- function fiveDaysAgo ( ) {
365- return daysAgo ( 5 ) ;
366- }
367-
368- function sixtyDaysAgo ( ) {
369- return daysAgo ( 60 ) ;
370- }
371-
372- function daysAgo ( days ) {
373- let now = new Date ( ) ;
374- return now . getTime ( ) - days * 24 * 60 * 60 * 1000 ;
375- }
0 commit comments