Skip to content

Commit

Permalink
shift test stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 18, 2024
1 parent f633165 commit aba56f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/lib/smooch_nlu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_team_with_smooch_bot_installed
team = create_team_with_smooch_bot_installed
nlu = SmoochNlu.new(team.slug)
nlu.enable!
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/text/similarity/' }.once
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/similarity/sync/text' }.once
nlu.add_keyword_to_menu_option('en', 'main', 0, 'subscribe')
expected_output = {
'en' => {
Expand All @@ -85,17 +85,17 @@ def create_team_with_smooch_bot_installed
end

test 'should add keyword if it does not exist' do
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/text/similarity/' }.once
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/similarity/sync/text' }.once
team = create_team_with_smooch_bot_installed
SmoochNlu.new(team.slug).add_keyword_to_menu_option('en', 'main', 0, 'subscribe to the newsletter')
end

test 'should not add keyword if it exists' do
team = create_team_with_smooch_bot_installed
nlu = SmoochNlu.new(team.slug)
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/text/similarity/' }.once
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/similarity/sync/text' }.once
nlu.add_keyword_to_menu_option('en', 'main', 0, 'subscribe to the newsletter')
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/text/similarity/' }.never
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'post' && y == '/similarity/sync/text' }.never
nlu.add_keyword_to_menu_option('en', 'main', 0, 'subscribe to the newsletter')
end

Expand All @@ -114,7 +114,7 @@ def create_team_with_smooch_bot_installed
end

test 'should return a menu option if NLU is enabled' do
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/text/similarity/search/' && z[:text] =~ /newsletter/ }.returns({ 'result' => [
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/similarity/sync/text' && z[:text] =~ /newsletter/ }.returns({ 'result' => [
{ '_score' => 0.9, '_source' => { 'context' => { 'menu_option_id' => 'test' } } },
]})
team = create_team_with_smooch_bot_installed
Expand Down

0 comments on commit aba56f8

Please sign in to comment.