Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

36 mock websocket #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ jobs:
make build

- name: Run linter
run: make lint
run: make lint

- name: Run test
run: make test
4 changes: 1 addition & 3 deletions __fixtures__/getRemoveResponse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const getRemoveResponse = gameId => ({
data: JSON.stringify([null, null, 'lobby', 'game:remove', { id: gameId }]),
});
const getRemoveResponse = gameId => (JSON.stringify([null, null, 'lobby', 'game:remove', { id: gameId }]));

export default getRemoveResponse;
64 changes: 31 additions & 33 deletions __fixtures__/getUpdateResponse.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
const getUpdateResponse = (gameId, state = 'waiting_opponent') => ({
data: JSON.stringify([null,
null,
'lobby',
'game:upsert',
{
game: {
id: gameId,
inserted_at: '2020-10-04T22:38:22',
const getUpdateResponse = (gameId, state = 'waiting_opponent') => (JSON.stringify([null,
null,
'lobby',
'game:upsert',
{
game: {
id: gameId,
inserted_at: '2020-10-04T22:38:22',
is_bot: false,
level: 'elementary',
players: [{
id: 2782,
name: 'H9ko',
is_bot: false,
level: 'elementary',
players: [{
id: 2782,
name: 'H9ko',
is_bot: false,
github_id: 57991929,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [], asserts_count: 0, output: '', result: '{"status": "info"}', status: 'initial', success_count: 0,
},
achievements: ['played_ten_games', 'played_fifty_games'],
rating: 1152,
rating_diff: 0,
}],
state,
timeout_seconds: 7200,
type: 'public',
},
}]),
});
github_id: 57991929,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [], asserts_count: 0, output: '', result: '{"status": "info"}', status: 'initial', success_count: 0,
},
achievements: ['played_ten_games', 'played_fifty_games'],
rating: 1152,
rating_diff: 0,
}],
state,
timeout_seconds: 7200,
type: 'public',
},
}]));

export default getUpdateResponse;
306 changes: 152 additions & 154 deletions __fixtures__/phxReply4bots.js
Original file line number Diff line number Diff line change
@@ -1,159 +1,157 @@
export default {
data: JSON.stringify([
'7',
'7',
'lobby',
'phx_reply',
{
response: {
active_games: [
{
id: 19887,
inserted_at: '2020-09-27T13:30:54',
is_bot: true,
level: 'medium',
players: [
{
id: -27,
name: 'HappyQleaner',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
achievements: [
'played_hundred_games',
'win_games_with?clojure_cpp_csharp_golang_haskell_js_kotlin_php_python_ruby',
],
rating: 1365,
rating_diff: 0,
export default JSON.stringify([
'7',
'7',
'lobby',
'phx_reply',
{
response: {
active_games: [
{
id: 19887,
inserted_at: '2020-09-27T13:30:54',
is_bot: true,
level: 'medium',
players: [
{
id: -27,
name: 'HappyQleaner',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 19923,
inserted_at: '2020-09-28T12:17:11',
is_bot: true,
level: 'hard',
players: [
{
id: -18,
name: 'DenisPython',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
achievements: [
'played_hundred_games',
'win_games_with?cpp_csharp_elixir_golang_haskell_java_js_php_python_ruby_ts',
],
rating: 1344,
rating_diff: 0,
achievements: [
'played_hundred_games',
'win_games_with?clojure_cpp_csharp_golang_haskell_js_kotlin_php_python_ruby',
],
rating: 1365,
rating_diff: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 19923,
inserted_at: '2020-09-28T12:17:11',
is_bot: true,
level: 'hard',
players: [
{
id: -18,
name: 'DenisPython',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 20011,
inserted_at: '2020-09-30T16:15:49',
is_bot: true,
level: 'elementary',
players: [
{
id: -9,
name: 'UlaBack',
is_bot: true,
github_id: 35539033,
lang: 'ruby',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'ruby',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
achievements: [
'played_hundred_games',
'win_games_with?cpp_csharp_elixir_haskell_java_js_php_python_ruby',
],
rating: 1261,
rating_diff: 0,
achievements: [
'played_hundred_games',
'win_games_with?cpp_csharp_elixir_golang_haskell_java_js_php_python_ruby_ts',
],
rating: 1344,
rating_diff: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 20011,
inserted_at: '2020-09-30T16:15:49',
is_bot: true,
level: 'elementary',
players: [
{
id: -9,
name: 'UlaBack',
is_bot: true,
github_id: 35539033,
lang: 'ruby',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'ruby',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 20013,
inserted_at: '2020-09-30T17:14:20',
is_bot: true,
level: 'easy',
players: [
{
id: -5,
name: 'ValyaFront',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
achievements: [
'played_hundred_games',
'win_games_with?clojure_cpp_elixir_golang_java_js_php_python_ruby',
],
rating: 1287,
rating_diff: 0,
achievements: [
'played_hundred_games',
'win_games_with?cpp_csharp_elixir_haskell_java_js_php_python_ruby',
],
rating: 1261,
rating_diff: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
{
id: 20013,
inserted_at: '2020-09-30T17:14:20',
is_bot: true,
level: 'easy',
players: [
{
id: -5,
name: 'ValyaFront',
is_bot: true,
github_id: 35539033,
lang: 'js',
editor_text: 'module.exports = () => {\n\n};',
editor_lang: 'js',
creator: true,
game_result: 'undefined',
check_result: {
asserts: [],
asserts_count: 0,
output: '',
result: '{"status": "info"}',
status: 'initial',
success_count: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
],
},
status: 'ok',
achievements: [
'played_hundred_games',
'win_games_with?clojure_cpp_elixir_golang_java_js_php_python_ruby',
],
rating: 1287,
rating_diff: 0,
},
],
state: 'waiting_opponent',
timeout_seconds: 3600,
type: 'bot',
},
],
},
]),
};
status: 'ok',
},
]);
Loading