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

Бёрдов Дмитрий #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion formatDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const MONTHLIST = ['января', 'февраля', 'марта', 'апреля', 'мая','июня', 'июля',
'августа', 'сентября','октября', 'ноября', 'декабря']

function formatDate(date) {
// Напишите код форматирования даты в этом месте
if(!(arguments.length == 1))
throw new Error('Некорректное число аргументов функции');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А где всё остальное?


module.exports = formatDate;
16 changes: 12 additions & 4 deletions showTweets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const formatDate = require('./formatDate');

const request = require('request');

function showTweets() {
// Здесь будет код, который получает твиты и
// выводит их на консоль
request('https://api.twitter.com/1.1/search/tweets.json?q=%23urfu-testing-2016', (err, resp, body) => {
if ((resp.statusCode !== 200) | err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем ты применяешь побитовые операции |?
логическое или пишется ||

console.error("Status: " + resp.statusCode + " Error: " + err)
return;
}

body = JSON.parse(body);
console.log(body);
});
}

module.exports = showTweets;
11 changes: 11 additions & 0 deletions tests/formatDate_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const assert = require('assert');
const formatDate = require('../formatDate');

it('should throw error `Некорректное число аргументов функции`', () => {
try {
formatDate('42', 'Сорок два');
throw new Error('`formatDate` should throw error')
} catch (error) {
assert.equal(error.message, 'Некорректное число аргументов функции');
}
});