Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
M
matrix-appservice-discord
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
matrix-appservice-discord
Validations
367e76d2
Valider
367e76d2
rédigé
7 years ago
par
Will Hunt
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Complete tests for MRH
parent
7720262d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
test/mocks/channel.ts
+1
-2
1 ajout, 2 suppressions
test/mocks/channel.ts
test/test_matrixroomhandler.ts
+54
-0
54 ajouts, 0 suppression
test/test_matrixroomhandler.ts
avec
55 ajouts
et
2 suppressions
test/mocks/channel.ts
+
1
−
2
Voir le fichier @
367e76d2
import
{
MockUser
}
from
"
./user
"
;
import
*
as
Discord
from
"
discord.js
"
;
import
{
MockMember
}
from
"
./member
"
;
import
{
MockCollection
}
from
"
./collection
"
;
// Mocking TextChannel
export
class
MockChannel
{
constructor
(
public
id
:
string
=
""
,
public
guild
:
any
=
null
)
{
}
public
members
=
new
MockCollection
<
string
,
MockMember
>
();
}
Ce diff est replié.
Cliquez pour l'agrandir.
test/test_matrixroomhandler.ts
+
54
−
0
Voir le fichier @
367e76d2
...
...
@@ -11,6 +11,7 @@ import {MockChannel} from "./mocks/channel";
import
{
MockMember
}
from
"
./mocks/member
"
;
import
*
as
Bluebird
from
"
bluebird
"
;
import
{
MockGuild
}
from
"
./mocks/guild
"
;
import
{
Guild
}
from
"
discord.js
"
;
Chai
.
use
(
ChaiAsPromised
);
const
expect
=
Chai
.
expect
;
...
...
@@ -479,4 +480,57 @@ describe("MatrixRoomHandler", () => {
return
expect
(
handler
.
tpParseUser
(
"
alias
"
)).
to
.
eventually
.
be
.
rejected
;
});
});
describe
(
"
joinRoom
"
,
()
=>
{
it
(
"
will join immediately
"
,
()
=>
{
const
handler
:
any
=
createRH
({});
const
intent
=
{
getClient
:
()
=>
{
return
{
joinRoom
:
()
=>
{
return
Promise
.
resolve
();
}
};
}
};
const
startTime
=
Date
.
now
();
const
MAXTIME
=
1000
;
return
expect
(
handler
.
joinRoom
(
intent
,
"
#test:localhost
"
)).
to
.
eventually
.
be
.
fulfilled
.
and
.
satisfy
(()
=>
{
return
(
Date
.
now
()
-
startTime
)
<
MAXTIME
;
});
});
it
(
"
will fail first, join after
"
,
()
=>
{
log
.
level
=
"
error
"
;
const
handler
:
any
=
createRH
({});
let
shouldFail
=
true
;
const
intent
=
{
getClient
:
()
=>
{
return
{
joinRoom
:
()
=>
{
if
(
shouldFail
)
{
shouldFail
=
false
;
return
Promise
.
reject
(
"
Test failed first time
"
);
}
return
Promise
.
resolve
();
},
getUserId
:
()
=>
"
@test:localhost
"
,
};
}
};
const
startTime
=
Date
.
now
();
const
MINTIME
=
1000
;
return
expect
(
handler
.
joinRoom
(
intent
,
"
#test:localhost
"
)).
to
.
eventually
.
be
.
fulfilled
.
and
.
satisfy
(()
=>
{
expect
(
shouldFail
).
to
.
be
.
false
;
return
(
Date
.
now
()
-
startTime
)
>
MINTIME
;
});
});
});
describe
(
"
createMatrixRoom
"
,
()
=>
{
it
(
"
will return an object
"
,
()
=>
{
const
handler
:
any
=
createRH
({});
const
channel
=
new
MockChannel
(
"
123
"
,
new
MockGuild
(
"
456
"
));
const
roomOpts
=
handler
.
createMatrixRoom
(
channel
,
"
#test:localhost
"
);
expect
(
roomOpts
.
creationOpts
).
to
.
exist
;
expect
(
roomOpts
.
remote
).
to
.
exist
;
});
});
});
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter