From 917ae93a54ba9eabbc02e97ebc15e148496c86ca Mon Sep 17 00:00:00 2001 From: Guillermo Giuliana Date: Mon, 13 Dec 2021 18:09:51 -0300 Subject: [PATCH] add new topic ruby tests --- tests/article/topic.rb | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/article/topic.rb b/tests/article/topic.rb index 3510b99b..07fb48f5 100644 --- a/tests/article/topic.rb +++ b/tests/article/topic.rb @@ -24,6 +24,19 @@ describe 'Topic paths' do (lastLog['type']).should.equal('ADD_TOPIC') end + it 'should success if topic has same name' do + result = request('/article/edit-topic', { + topicId: 1, + name: 'Server management', + iconColor: 'blue', + private: 1, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + (result['status']).should.equal('success') + end + it 'should edit topic correctly' do result = request('/article/edit-topic', { topicId: 1, @@ -43,6 +56,47 @@ describe 'Topic paths' do (topic['private']).should.equal(1) end + it 'should fail if data is already in use' do + result = request('/article/add-topic', { + name: 'Installation issues', + icon: 'cogs', + iconColor: 'red', + private: 0, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('NAME_ALREADY_USED') + end + + it 'should edit topic if data is right without name' do + result = request('/article/add-topic', { + name: 'Valid name', + icon: 'cogs', + iconColor: 'red', + private: 0, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + (result['status']).should.equal('success') + + topic = $database.getLastRow('topic') + + result = request('/article/edit-topic', { + name: 'Valid name', + topicId: topic['id'], + iconColor: 'pink', + icon: 'flag', + private: 1, + csrf_userid: $csrf_userid, + csrf_token: $csrf_token + }) + + (result['status']).should.equal('success') + end + it 'should delete topic correctly' do result = request('/article/delete-topic', { topicId: 1,