File tree Expand file tree Collapse file tree
spec/crowdin-api/api_resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'spec_helper'
4+
5+ describe Crowdin::ApiResources::Ai do
6+ describe '#ai_translate_strings' do
7+ let(:user_id) { 1 }
8+
9+ context 'in Crowdin mode (non-enterprise)' do
10+ it 'when request are valid' do
11+ stub_request(:post, "https://api.crowdin.com/api/v2/users/#{user_id}/ai/translations/translate-strings")
12+ .to_return(
13+ status: 200,
14+ body: {
15+ data: {
16+ translations: ['Hallo Welt']
17+ }
18+ }.to_json
19+ )
20+
21+ result = @crowdin.ai_translate_strings(user_id, { strings: ['Hello'], targetLanguageId: 'de' })
22+ expect(result['data']['translations']).to eq(['Hallo Welt'])
23+ end
24+ end
25+
26+ context 'in Enterprise mode', :enterprise do
27+ it 'when request are valid' do
28+ stub_request(:post, "https://#{organization_domain}.api.crowdin.com/api/v2/ai/translations/translate-strings")
29+ .to_return(
30+ status: 200,
31+ body: {
32+ data: {
33+ translations: ['Hallo Welt']
34+ }
35+ }.to_json
36+ )
37+
38+ result = @crowdin.ai_translate_strings(user_id, { strings: ['Hello'], targetLanguageId: 'de' })
39+ expect(result['data']['translations']).to eq(['Hallo Welt'])
40+ end
41+ end
42+
43+ it 'should raise error when user_id is missing' do
44+ expect { @crowdin.ai_translate_strings(nil, { strings: ['Hello'] }) }
45+ .to raise_error(ArgumentError)
46+ end
47+ end
48+ end
File renamed without changes.
You can’t perform that action at this time.
0 commit comments