MCPcopy Create free account
hub / github.com/Canop/codesort / test_javascript_assigns

Function test_javascript_assigns

tests/javascript_assigns.rs:4–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3#[test]
4fn test_javascript_assigns() {
5 static INPUT: &str = r#"
6 miaou(function(notif, chat, gui, horn, locals, md, prefs, watch, ws){
7
8 var notifications = [], // array of {r:roomId, rname:roomname, mid:messageid}
9 notifMessage, // an object created with md.notificationMessage displaying notifications
10 hasWatchUnseen = false,
11 nbUnseenMessages = 0,
12 lastUserAction = 0; // ms
13
14 notif.updatePingsList = function(){
15 if (!vis()) notif.updateTab(!!notifications.length, nbUnseenMessages);
16 if (!notifications.length) {
17 if (notifMessage) notifMessage.$md.slideUp($.fn.remove);
18 notifMessage = null;
19 watch.setPings([]);
20 return;
21 }
22 if (notifMessage) notifMessage.remove();
23 var localPings = [], otherRooms = {};
24 notifications.forEach(function(n){
25 if (locals.room.id==n.r) {
26 localPings.push(n);
27 } else {
28 otherRooms[n.r] = n.rname;
29 }
30 });
31 notifMessage = md.notificationMessage(function($c){
32 if (localPings.length) {
33 $('<div>').addClass('pingroom').append(
34 $('<span>').text(
35 localPings.length +
36 (localPings.length>1 ? ' pings' : ' ping') + ' in this room.'
37 )
38 ).append(
39 $('<button>').addClass('nextping').text("Next ping").click(function(){
40 notif.nextPing();
41 notif.updatePingsList();
42 })
43 ).append(
44 $('<button>').addClass('clearpings').text('clear').click(function(){
45 notif.clearPings(locals.room.id);
46 })
47 ).appendTo($c)
48 }
49 var otherRoomIds = Object.keys(otherRooms),
50 nbotherrooms = otherRoomIds.length;
51 if (nbotherrooms) {
52 var t = "You've been pinged in room";
53 if (nbotherrooms>1) t += 's';
54 var $otherrooms = $('<div>').append($('<span>').text(t)).appendTo($c);
55 $.each(otherRooms, function(r, rname){
56 var $brs = $('<div>').addClass('pingroom').appendTo($otherrooms);
57 $('<button>').addClass('openroom').text(rname).click(function(){
58 ws.emit('watch_raz');
59 setTimeout(function(){ location = r; }, 250); // timeout so that the raz is sent
60 }).appendTo($brs);
61 $('<button>').addClass('clearpings').text('clear').click(function(){

Callers

nothing calls this directly

Calls 4

focusMethod · 0.80
into_blocksMethod · 0.80
sortMethod · 0.80
print_debugMethod · 0.45

Tested by

no test coverage detected